An IPython notebook is saved in a JSON text file. This file contains the entire contents of the notebook: text, code, and outputs. The matplotlib figures are encoded as base64 strings within the notebooks, resulting in standalone, but sometimes big, notebook files.
json module in Python's standard library).
IPython comes with a tool called nbconvert that can convert notebooks to other formats: ...