An .ipynb file is one JSON
object whose shape is fixed by the nbformat JSON schemas published by Project Jupyter.
Sources: the nbformat
format description
(nbformat 4) and the JSON schemas in the
jupyter/nbformat repository,
nbformat.v4.5.schema.json and nbformat.v3.schema.json. The
version history is checked against the
nbformat CHANGELOG.md
(the raw file, read 2026-11-14), the six schema files nbformat.v4.0 to
v4.5.schema.json compared pairwise, JEP 62 (Cell ID Addition to
Notebook Format, raw 62-cell-id/cell-id.md in
jupyter/enhancement-proposals), and for nbformat 1 and 2 the package’s
nbformat/v1 and nbformat/v2 modules (raw).
Top level
| Key | Type | Meaning |
|---|---|---|
nbformat | integer | Major version: 4. A change means files are not backward compatible. |
nbformat_minor | integer | Minor version, 0 to 5 (each version’s schema file sets this key’s minimum to its own minor number, 0 in the 4.0 file up to 5 in the 4.5 file). The key is listed under required in the 4.5 schema and in the version 3 schema alike ("required": ["metadata", "nbformat_minor", "nbformat", …]), so it is not specific to version 4. A reader keeps, but need not show, cell and output types it does not know. |
metadata | object | Notebook metadata; see below. |
cells | array | The cells, in order. |
Multi-line strings. Fields such as code input and text output may be stored either as one string or as an array of strings. Readers must accept both; nbformat’s own Python and JavaScript APIs always return one joined string.
Notebook metadata
| Key | Type | Meaning |
|---|---|---|
kernel_info | object | Appears in the example of the 4.x format description (format_description.rst, raw) with the comment “if kernel_info is defined, its name field is required”; its only example field is name (the name of the kernel). The 4.5 schema file has no kernel_info property, and metadata allows extra keys (additionalProperties: true), so for 4.x the key is documented only by that example; the version 3 schema defines it (see the version 3 table). |
kernelspec | object | The kernel specification: name and display_name, both required strings. |
language_info | object | The kernel’s language: name (required), and in the schema codemirror_mode (string or object), file_extension, mimetype, pygments_lexer; the format description also shows version. |
authors | array | The author(s). The format description says each is an object of which only name (a string, the author’s full name) is required and further fields may be added. The schema files (4.2 to 4.5) declare the array’s element rule under the key item, not items, so a validator does not check the elements. |
title | string | The notebook’s title (added in the 4.2 schema). |
orig_nbformat | integer, at least 1 | Major version the file had before it was converted. The schema description (already in the 4.0 schema file) says “This should never be written to a file.”, but nbformat’s own conversion does write it into metadata (see version detection and conversion). |
The schema allows other keys here. For cell metadata the description asks that
custom keys use a unique namespace, with official Jupyter keys under
jupyter.
Cells
| Key | Cell types | Meaning |
|---|---|---|
cell_type | all | "code", "markdown" or "raw". |
id | all (4.5) | 1 to 64 characters from A–Z a–z 0–9 - _, unique within the notebook. Required from nbformat 4.5; absent before it. |
metadata | all | Cell metadata; see below. |
source | all | The cell’s text (multi-line string). |
attachments | markdown, raw (4.1, backported to 4.0) | File names mapped to MIME bundles, e.g. {"test.png": {"image/png": "…"}}, so the Markdown can show them inline. The Markdown refers to one with the link form attachment:file name, as in . Optional; may be missing or empty. |
execution_count | code | Integer of 0 or more, or null if never run (schema: "type": ["integer", "null"], "minimum": 0). |
outputs | code | Array of outputs; see below. |
Markdown cells are GitHub-flavoured Markdown. A raw cell is not rendered in the
notebook; its metadata.format (a MIME type) names the nbconvert output it
goes into, other formats leave it out, and without it the cell goes into all. Code
cells require outputs and execution_count; no cell may
carry keys outside its list, but cell metadata may.
Cell metadata
| Key | Type | Meaning |
|---|---|---|
collapsed | boolean | Code cells: the output area is collapsed. |
scrolled | boolean or "auto" | Code cells: the output area scrolls. |
deletable | boolean | false: the cell cannot be deleted. |
editable | boolean | false: the cell cannot be edited (nor deleted). |
format | MIME type | Raw cells: the target format. |
name | non-empty string | A name (pattern ^.+$), expected to be unique in the notebook; the schema cannot check uniqueness, so a separate check must. |
tags | array of strings | Tags, unique within the array; no commas inside a tag. |
jupyter | object | Official Jupyter front-end fields (other keys allowed): source_hidden (boolean, whether the source is hidden) for code, markdown and raw cells, and outputs_hidden (boolean) for code cells only. In the 4.3 to 4.5 schema files these two sit directly under jupyter beside type, not inside a properties object, so a validator does not enforce their type. |
execution | object | ISO 8601 times of the last run: iopub.execute_input (request received), iopub.status.busy (work started), shell.execute_reply (finished), iopub.status.idle (kernel idle again). |
Outputs
output_type | Keys | Meaning |
|---|---|---|
stream | name ("stdout" or "stderr"), text | Printed text. |
display_data | data (MIME bundle), metadata | Rich output from a display call. |
execute_result | data, metadata, execution_count | The value of the cell’s last expression. All four keys required; execution_count is an integer of 0 or more or null in the schema (the format description says “must be an integer”). |
error | ename, evalue, traceback (array of strings) | An exception. |
metadata is keyed by MIME type, e.g.
{"image/png": {"width": 640, "height": 480}}; the key
isolated (boolean) asks for the output to be shown in an iframe.
MIME bundles
A MIME bundle has MIME types as keys and the content as values, such as
text/plain text or image/png data, which the format
description’s examples store as base64 multi-line text.
application/json, and from 4.2 any type ending +json
(backported to 4.0), hold JSON as it is, not serialised into a string. An output of
an unknown output_type is not valid for a notebook whose nbformat_minor is within the validating library’s; see the unrecognised cells and outputs rule.
Versions
| Version | Change |
|---|---|
| 4.0 | The version-3 worksheets array gives way to a top-level cells array (from comparing the two schemas). Heading cells removed (Markdown headings instead). input renamed source, prompt_number renamed execution_count, pyout renamed execute_result, pyerr renamed error, stream’s stream key renamed name; output data moved into data keyed by full MIME type. |
| 4.1 | Cell attachments on markdown and raw cells (CHANGELOG 4.1). The 4.0 and 4.1 schema files differ only in the description and the nbformat_minor minimum. |
| 4.2 | Mime types of the form application/anything+json, and JSON outputs of any JSON type, not only objects (CHANGELOG 4.2). metadata.title (string) and metadata.authors (list of objects with name, the full name; CHANGELOG: “Define basics of authors”) are first in the 4.2 schema. The cell name description gains “Must be unique across all the cells of a given notebook”. |
| 4.3 | The 4.3 schema file adds metadata.jupyter to all three cell types, with source_hidden (and outputs_hidden for code cells). The CHANGELOG lists the library’s metadata.jupyter entry under 4.4 (and the 4.0 to 4.3 schema files were written later, in release 5.0: “Documented notebook format versions 4.0-4.3 with accurate json schema specification files”); its 4.3 entries are library changes (a pluggable SignatureStore for trusted-notebook signatures, bytes file paths, validation fixes). |
| 4.4 | States that metadata fields can be ignored. Introduces the official metadata.jupyter namespace and, inside it, source_hidden and outputs_hidden as official front-end fields to hide the source and outputs areas (they are not to be used to hide elements in exported formats). The 4.4 schema is the first to carry the code-cell metadata.execution timings (iopub.execute_input, iopub.status.busy, shell.execute_reply, iopub.status.idle, ISO 8601 strings; any other key must also be a string), which the CHANGELOG records under release 5.0 (“Add execution timings in code cell metadata for v4 spec”). The collapsed description now says it concerns the output, and the cell name description says uniqueness “cannot be checked by the json schema”. |
| 4.5 | Required cell id (see cell ids). |
Nothing else differs between consecutive schema files (checked with diff); the
orig_nbformat minimum of 1 is in all of them. The CHANGELOG also records, for
release 5.0.5, that “notebook format 4.0 and 4.1 [may] have the arbitrary JSON mimebundles
from format 4.2 for pragmatic purposes”, and for 5.1.1 that the library upgrades 4.x notebooks
to 4.5.
Validity rules (nbformat 4)
Sources, all raw files of the jupyter/nbformat main branch: nbformat.v4.5.schema.json (read in full), validator.py, reader.py, __init__.py, v4/convert.py, v4/nbbase.py and v3/convert.py. “The 4.5 schema” below; the 4.0 to 4.4 schema files are the same except for the differences in the versions table (no id before 4.5).
Required keys and no extras
| Object | Required keys | Other keys |
|---|---|---|
| Notebook (top level) | metadata, nbformat_minor, nbformat, cells | None: additionalProperties: false. nbformat is an integer with minimum and maximum both 4; nbformat_minor an integer with minimum equal to the schema’s own minor (5 in the 4.5 file). metadata allows any further keys. |
| Raw cell | id, cell_type ("raw"), metadata, source | Only attachments besides the required four. Cell metadata allows any keys. |
| Markdown cell | id, cell_type ("markdown"), metadata, source | Only attachments. |
| Code cell | id, cell_type ("code"), metadata, source, outputs, execution_count | None (no attachments). |
execute_result | output_type, data, metadata, execution_count | None. |
display_data | output_type, data, metadata | None. |
stream | output_type, name, text | None. name is any string (the schema’s description names stdout and stderr). |
error | output_type, ename, evalue, traceback | None. |
A cell must match exactly one of the three cell definitions, an output exactly one of the four output definitions (oneOf); an output’s metadata is any object. A MIME bundle (data, and each attachment) is an object whose values are a string or an array of strings, except that a key matching ^application/(.*\+)?json$ may hold any JSON value. attachments is an object keyed by file name, each value a MIME bundle.
Cell ids in the validator
For a notebook of version 4.5 or later, validator.py’s normalisation step (run by validate) gives a cell with no id a generated one and issues a MissingIDFieldWarning; a repeated id is replaced by a new generated one with a DuplicateCellId warning. Only when repair is turned off is a repeated id an error (“Non-unique cell id”). The schema itself cannot check uniqueness.
Unrecognised cells and outputs
The schema file defines unrecognized_cell (an object that requires cell_type, with a value other than markdown, code or raw, and metadata; any other keys allowed) and unrecognized_output (requires output_type, not one of the four known values; any other keys allowed), but the schema’s cell and output lists do not refer to them. That is done by validator.py, in get_validator: only when the notebook’s nbformat_minor is higher than the library’s own (nbformat_minor 5 in v4/nbbase.py), the library loads the latest schema, relaxes every additionalProperties in it to true, and appends the two definitions to the oneOf lists. So a notebook from a future minor version may contain new cell and output types and extra keys; for a notebook at or below the library’s minor version, an unknown cell or output type, or an extra key where the schema says additionalProperties: false, is an error. Validators that do not use nbformat may behave differently.
Version detection and conversion
Library behaviour. Everything in this list is what the nbformat Python library does (reader.py, v4/convert.py, v3/convert.py, read raw); none of it is a rule of the file format itself, and the schemas do not mention it. Other programs may convert differently. The detection default of version 1 and the error cases are likewise the library’s.
- Detection (
reader.get_version): the version isnbformat(default 1 when absent) andnbformat_minor(default 0). - Reading (
reader.reads): the text must be JSON (otherwiseNotJSONError, “Notebook does not appear to be JSON”); a major version that is not 1, 2, 3 or 4 raisesNBFormatError“Unsupported nbformat version n”; a missing expected key becomes aValidationError. - No schema: a (major, minor) pair that has no schema file and whose minor is not above the library’s gives “No schema for validating vmajor.minor notebooks”.
- Upgrade 4.x to 4.5 (
v4/convert.upgrade): a version 4 notebook withoutnbformat_minoris aValidationError(“does not include the nbformat minor”); a minor already 5 is returned unchanged; below 5 every cell gets a new randomid,metadata.orig_nbformat_minorrecords the old minor andnbformat_minorbecomes 5. - Upgrade 3 to 4 (same function,
upgrade_cell,upgrade_output):orig_nbformatandorig_nbformat_minorare moved from the top level intometadata(defaults 3 and 0);nbformatandnbformat_minorbecome 4 and 5; the worksheets are flattened, in order, intocells;metadata.nameandmetadata.signatureare dropped; every cell gets anidand ametadataobject; a code cell loseslanguage, itscollapsedmoves intometadata,inputbecomessourceandprompt_numberbecomesexecution_count(null when absent); aheadingcell becomes a markdown cell whose source is#repeated level times, a space and the source lines joined with single spaces; anhtmlcell becomes markdown. Outputs:pyoutbecomesexecute_result(prompt_numberbecomesexecution_count),pyerrbecomeserror, a stream’sstreamkey becomesname(defaultstdout), and inpyoutanddisplay_dataevery key other thanoutput_type,execution_countandmetadatamoves intodata, with the short keys renamed to MIME types (also in the output’smetadata),application/jsonparsed from its string into a JSON value, and base64 image bytes turned into text. - Downgrade 4 to 3 (
downgrade):nbformatandnbformat_minortake the version-3 values, the cells go into one worksheet; code cells getlanguagepython,input,prompt_numberandcollapsed(default false, taken frommetadata.collapsed); a markdown cell of one line that starts with#becomes aheadingcell withlevelthe number of#characters;idandattachmentsare dropped; outputs are renamed back andapplication/jsonis serialised to a string;metadata.nameis set to the empty string if absent;orig_nbformatandorig_nbformat_minorare taken out ofmetadatato the top level (defaults 4 and 5). Short keys have no equivalent for MIME types outside the eight of the table below, so those data are not carried over.
Cell ids (JEP 62)
Source: JEP 62, Cell ID Addition to Notebook Format (status Implemented, dated
2020-09-25; raw 62-cell-id/cell-id.md), and the 4.5 schema. nbformat 5.1.0 implemented it
(CHANGELOG: “Implemented CellIds from JEP-62”).
- Where.
idis a key of the cell object itself, besidecell_type, not insidemetadata(whereadditionalPropertiesis true and a name might collide). It is in all three cell types and required in all of them from 4.5 on; making it optional was rejected because it would give partial implementations. - Form. A string of 1 to 64 characters matching
^[a-zA-Z0-9-_]+$: letters, digits,-and_, the unreserved URI characters minus.and~(RFC 3986), so an id can sit in a URL. The limit leaves room for a 36-character UUID. A UUID type was proposed and dropped. A numeric first character is allowed. - Unique in the notebook (the format description: “unique to any given Notebook”). Uniqueness across notebooks is not a goal, though a managed system may rely on it.
- Older notebooks. When a notebook from an older format is loaded, ids are filled in with unique values (the JEP’s reference uses
uuid.uuid4().hex[:8]; it lists other strategies: an integer counter, 64-bit random ids, uuid subsets, or joined words, and prefers readable words, else random). The JEP recommends auto-updating older notebooks to 4.5, and filling a missing id on save rather than raising an error, while an invalid id still raises one. - Stability. An id does not change when the cell’s content changes (“It stays the same once created”, even if the content is cut out and pasted into a new cell); it is created once.
- Paste. A pasted cell is given a new id if and only if its id is already in use in the notebook; otherwise the application may keep it. After a cut and paste the id may be kept, but a second paste of the same clipboard needs a new id.
- Splitting a cell. One half (the JEP suggests the top half) keeps the id and the other gets a new one; the JEP leaves the rest to the application so long as ids stay unique and valid.
- Other notebooks. Whether a cell moved to another notebook keeps its id depends on the application.
- Loading errors. A 4.5 or later file with an invalid id is a validation error, like any schema error (an application could choose to correct it).
- User view. Users need not see or edit ids; applications need no interface change to support 4.5.
nbformat 3
Source: nbformat.v3.schema.json (“IPython Notebook v3.0 JSON schema”, draft-04, read in full) and
nbformat/v3/convert.py. Version 3 keeps cells in worksheets. Every object listed below
has additionalProperties: false except where the metadata rows say otherwise.
Top level
| Key | Required | Type | Meaning |
|---|---|---|---|
metadata | yes | object, other keys allowed | Notebook root-level metadata, with the two known keys below. |
nbformat | yes | integer, 3 to 3 | Major version. |
nbformat_minor | yes | integer, 0 or more | Minor version. |
worksheets | yes | array of worksheets | See below. |
orig_nbformat | no | integer, 1 or more | Major version before conversion. |
orig_nbformat_minor | no | integer, 0 or more | Minor version before conversion. |
Notebook metadata
| Key | Type | Meaning |
|---|---|---|
kernel_info | object; name and language required | name: name of the kernel specification (string). language: the language the kernel runs (string). codemirror_mode (optional, string only in v3, unlike the string-or-object of 4.x): the CodeMirror mode for the language. (The 4.x format description’s example shows only name as required; the v3 schema requires both.) |
signature | string | “Hash of the notebook” (the schema’s whole description). Meaning, from nbformat’s sign.py (raw): it is the trust signature of the notebook, an HMAC hex digest (hmac.hexdigest()) computed with a secret key held on the user’s machine and a hash algorithm (default sha256) over the whole notebook, in the order of yield_everything: for a dictionary, its keys sorted, each key as UTF-8 bytes followed by the bytes of its value; for a list, the bytes of each element in turn; a string as UTF-8; any other value as the UTF-8 of str(value). The metadata.signature key itself is removed before hashing, so the stored hash is not part of its own input. A notebook is trusted when its recomputed digest is known. The docstring of check_signature still describes the stored form as scheme:hexdigest, but the current code keeps the (algorithm, digest) pairs in a local trust store (an SQLite table nbsignatures by default), not in the file, and marks outputs as trusted with metadata.trusted on code cells. Without the machine’s secret the value cannot be verified by a reader of the file. |
Worksheet
Object with required cells (array of cells) and optional metadata (an object, “metadata of the current worksheet”). No other keys.
Cells
cell_type | Required keys | Other keys |
|---|---|---|
raw | cell_type, source | metadata (object, other keys allowed): format (string, the nbconvert format), name (non-empty string, ^.+$), tags (array of unique strings without commas). |
markdown or html | cell_type, source | metadata: name, tags as above, other keys allowed. (The cell_type enum is ["markdown", "html"].) |
heading | cell_type, source, level | level integer, 1 or more; metadata any object (no name or tags rules). |
code | cell_type, input, outputs, language | language (string; “the cell’s language (always Python)”), collapsed (boolean), metadata (any object), prompt_number (integer of 0 or more, or null if never run; not required), outputs (array of outputs). |
In a v3 cell the text is under source (markdown, raw, heading) or input
(code), each a string or an array of strings (joined with nothing). Cell metadata sits at the cell’s metadata key, not at the top.
Outputs
output_type | Required | Keys |
|---|---|---|
pyout | output_type, prompt_number | prompt_number (integer, 0 or more; not null here), the data keys below, metadata. |
display_data | output_type | the data keys below, metadata. |
stream | output_type, stream, text | stream (string, “the stream type/destination”), text (string or array of strings). |
pyerr | output_type, ename, evalue, traceback | strings, and traceback an array of strings. |
Data keys of pyout and display_data, each a string or an array of strings:
the short keys text, latex, png, jpeg, svg,
html, javascript, json and pdf, and also any
full MIME type (a patternProperties rule, ^[a-zA-Z0-9]+/[a-zA-Z0-9\-\+\.]+$ in pyout
and the same without the leading ^ in display_data), so the 4.x style
"image/png" key is accepted in version 3 beside png. Output
metadata is a free object (additionalProperties: true), not keyed by MIME type
by any rule of the v3 schema.
Short data keys and their MIME types
The v3 schema lists the nine short keys without descriptions. Their meaning is the MIME type that v4/convert.py (_mime_map, raw) assigns to them when a notebook is upgraded, and v3/rwbase.py shows how the image keys are stored.
| v3 key | v4 MIME type | Content |
|---|---|---|
text | text/plain | Plain text (multi-line string). |
html | text/html | HTML. |
svg | image/svg+xml | SVG markup. |
png | image/png | A PNG image, base64 text in the file (rwbase encodes the bytes with base64 on writing and decodes on reading). |
jpeg | image/jpeg | A JPEG image, base64 text likewise. |
latex | text/latex | LaTeX. |
json | application/json | JSON, stored as a string in v3; the upgrade parses it into a JSON value. |
javascript | application/javascript | JavaScript. |
pdf | none | Allowed by the v3 schema (a string or array of strings) but absent from _mime_map; the upgrade leaves a pdf key in data under that name, and the nbformat v3 constructor has no argument for it. |
Version 3 and the older versions
convert.upgrade from version 2 sets nbformat to 3,
orig_nbformat to 2 and gives every cell a metadata object if it has none;
from 3 to a different minor it records orig_nbformat_minor. downgrade to 2
turns heading cells into markdown cells with # repeated level times plus a space before the text, and raw cells into
markdown cells. The v3 to v4 changes are in the versions table above.
nbformat 1 and 2
Both are covered here as historical formats of the same .ipynb extension (the nbformat package keeps readers
for them in its v1 and v2 modules). The sources are those modules, read raw
(nbbase.py, nbjson.py, rwbase.py, convert.py, nbxml.py,
nbpy.py, __init__.py); neither version has a JSON schema file, so what follows is what those modules
write and read, not a validation schema.
Version 1
- JSON (
json.dumpswithindent=4) of an object with acellslist.new_notebookwrites nonbformatkey, and there are no worksheets and no metadata. - A code cell has
cell_type"code", the source incode(notinput) and an optional integerprompt_number. No outputs are stored. - A text cell has
cell_type"text"and its text intext. - The module cannot be converted to:
upgradeinv1/convert.pyraises “Cannot convert to v1 notebook format”.
Version 2
- A JSON object with
nbformat: 2(the module also setsnbformat_minor = 0),worksheets(list) andmetadata. The writer usesindent=1and sorted keys. - Metadata (all optional):
name,authors(list; each author:name,email,affiliation,url),license,created,modified,gistid. - Worksheet:
cellslist, optionalname. - Code cell:
cell_type"code",language(default"python"),input,prompt_number,outputs(list),collapsed(boolean). - Text cells:
cell_type"markdown"or"html", withsourceand optionallyrendered(the rendered text). - Outputs:
output_typepyout(withprompt_number),display_data,streamorpyerr, with the short data keystext,png,jpeg,html,svg,latex,json,javascript(notpdf, which v3 added); apyerrhasetype,evalueandtraceback(list of strings) in the module’s constructor, whereas v3’s schema names the firstename. - Line splitting: on writing, the JSON writer splits
input, and in outputstext,html,svg,latex,javascript,json, and the text cells’sourceandrendered, into lists of lines (splitlines); the reader rejoins lists with\n. Note this differs from 4.x, where the pieces keep their newline and are joined with an empty string.pngandjpegare base64 text. - Other forms of version 2 that the module handled: a
.pyexport with# <nbformat>2</nbformat>and cell markers# <codecell>,# <htmlcell>,# <markdowncell>(not an.ipynbfile), and an XML form whose reader the package has removed for safety (nbxml.py: “The XML notebook format was deprecated before the Jupyter … Notebook was ever released”). - Upgrading from 1 (
v2/convert.py): all cells go into one worksheet; v1codecells become code cells (codetoinput,prompt_numberkept) and v1textcells becomemarkdowncells. There is no downgrade (“Downgrade from notebook v2 to v1 is not supported”).
Documented metadata of other projects
The schema allows other keys in metadata (notebook, cell and output level). The keys below are used by real notebooks and are documented or defined by the project named in each heading; each fact was read from that project’s own raw documentation or source. A key not listed here may still occur: it is not part of the notebook format.
language_info and kernelspec (Jupyter messaging and kernel specs)
Source: docs/messaging.rst (the kernel_info_reply message) and docs/kernels.rst of jupyter/jupyter_client, raw. A notebook’s language_info copies the reply’s language_info:
| Key | Meaning (messaging.rst) |
|---|---|
name | Name of the programming language the kernel implements (the IPython kernel returns python). |
version | Language version number (for example 2.7.3 for Python). |
mimetype | MIME type for script files in the language. |
file_extension | Extension including the dot, such as .py. |
pygments_lexer | Pygments lexer for highlighting; only needed if it differs from name. |
codemirror_mode | CodeMirror mode (string or object); only needed if it differs from name. |
nbconvert_exporter | The nbconvert exporter to use for notebooks written with this kernel, if it should be something other than the general script exporter. |
A notebook’s kernelspec copies the kernel’s kernel.json in part. The keys of kernel.json (kernels.rst) are:
| Key | Meaning |
|---|---|
argv | List of command-line arguments that start the kernel; {connection_file} in an argument is replaced by the path of the connection file. |
display_name | The kernel’s name for the UI; may contain any Unicode characters. (Also required in the notebook’s kernelspec by the schema.) |
language | The language of the kernel. When a notebook is loaded and no kernelspec has the notebook’s kernelspec.name, a kernel with the same language is used. Notebooks usually carry it as kernelspec.language. |
interrupt_mode (optional) | signal (default) or message: how a client interrupts a running cell. |
env (optional) | Environment variables set for the kernel; ${VAR} refers to an existing variable. |
metadata (optional) | Extra attributes for kernel selection, namespaced for the tool that writes them; jupyter_client itself recognises supported_encryption (a list such as ["curve"]). |
kernel_protocol_version (optional) | String: the kernel protocol version the kernel supports. |
The kernel name used in a notebook’s kernelspec.name must, per kernels.rst, consist only of ASCII letters, digits, -, . and _ (it also names the kernelspec directory).
Jupyter widgets (ipywidgets)
Sources: docs/source/embedding.md and packages/schema/v2/state.schema.json, view.schema.json of jupyter-widgets/ipywidgets, raw. A notebook may be saved with the current widget state “as metadata” (embedding.md, “Save Notebook Widget State”; “Clear Notebook Widget State” removes it). The state uses the MIME type application/vnd.jupyter.widget-state+json; each displayed widget has an output whose MIME bundle holds application/vnd.jupyter.widget-view+json. Where the state sits. The ipywidgets JupyterLab manager (python/jupyterlab_widgets/src/manager.ts, raw) writes it with setMetadata('widgets', { 'application/vnd.jupyter.widget-state+json': state }) and reads it back from getMetadata('widgets') by the same MIME key. So the notebook-level metadata key is widgets, an object whose single key is application/vnd.jupyter.widget-state+json, whose value is the state object below. VS Code’s Jupyter extension (src/platform/common/utils.ts, raw) types the same place as metadata.widgets["application/vnd.jupyter.widget-state+json"] with state (model id to model_module, model_module_version, model_name, state), version_major and version_minor. The ipywidgets documents (embedding.md) say only “as metadata”; the key name comes from this source code, not from a prose specification.
| Object | Key | Meaning (JSON schema v2) |
|---|---|---|
| State | version_major, version_minor | Format version, numbers; major fixed at 2, minor 0. Required, with state. |
| State | state | Object keyed by model id; each value requires model_name (name of the JavaScript class holding the model), model_module (JavaScript module) and state (the serialised model state, an object); optional model_module_version (a semver range) and buffers. |
| Buffer | buffers items | Binary buffers in the state; each requires path (array of object keys or array indices locating the value in state), data (the buffer encoded as text) and encoding (hex: RFC 4648 section 8, or base64: RFC 4648 section 4). |
| View | model_id | Required: the identifier of the widget model to display. version_major (2) and version_minor are optional. |
Version 1 schemas (raw packages/schema/v1/state.schema.json and view.schema.json, JSON Schema draft 4; the v2 files use draft 7). Compared with v2 (diff of the two state files read in this session):
- State:
version_majormust be exactly 1 (minimum and maximum 1);version_minoris a number with no limit (v2: fixed at 0);version_major,version_minorandstateare required. The top-level object and each model object (model_name,model_module,model_module_version,state) haveadditionalProperties: false, so any other key, includingbuffers, is invalid; v2 allows extra keys and adds the optionalbuffersarray. Each model requiresmodel_name,model_moduleandstate;model_module_versionis an optional semver range text. Thestateof a model is an object; the schema spells its extra-keys flagadditional_properties: true(with underscores, not a JSON Schema keyword, so it has no effect as written). - View:
model_id(text) is required;version_major(exactly 1) andversion_minor(a number) are optional;additionalPropertiesis false.
Papermill
Sources: docs/usage-parameterize.rst and papermill/engines.py, parameterize.py, execute.py, iorw.py of nteract/papermill, raw.
- Cell tag
parametersmarks the cell whose assignments are the default parameters. Papermill inserts a new code cell taggedinjected-parametersright after the firstparameterscell (at the top if none exists; an existing injected cell is replaced) holding only the overridden values; with report mode itsmetadata.jupyter.source_hiddenis true (parameterize.py). Report mode also setsmetadata.jupyter.source_hiddento true on every code cell of the notebook, not only the injected one (prepare_notebook_metadatainexecute.py, which loops over all cells withcell_type == 'code'; the same function writes the notebook’spapermill.input_pathandoutput_path). A cell taggedpapermill-error-cell-tagis an error marker papermill adds after a failure and removes before re-running. - Notebook metadata
papermill:version(papermill’s version),parameters(the values passed, an object),default_parameters(object, initially empty),environment_variables(object, initially empty),input_path,output_path,start_timeandend_time(ISO 8601 UTC strings;nulluntil set),duration(seconds, a number) andexception(trueif any cell failed, otherwisenullor false). - Cell metadata
papermill:status(pending,running,completedorfailed),start_time,end_time,duration(seconds) andexception(null,falsewhile running,trueon failure).
VS Code
Source: extensions/ipynb/src/serializers.ts of microsoft/vscode, raw. Cell metadata metadata.vscode.languageId (a string, the VS Code language id) is written on a code cell only when its language differs from the notebook’s preferred language, which is language_info.name or, when that is absent, the language of the first code cell; otherwise it is removed. A cell whose language id is raw is written as a raw cell. The serializer sorts all JSON keys alphabetically to keep diffs small.
Interpreter hash. Source: src/platform/common/utils.ts of microsoft/vscode-jupyter, raw (the NotebookMetadata type). When a Python environment has been selected for the notebook, the notebook metadata vscode.interpreter.hash (a string) holds, in the source’s words, the “hash of the interpreter executable path”. Older files kept it at metadata.interpreter.hash; the source marks that place deprecated (“we used to store interpreter at this level”). The same type also holds the widgets key described above.
The hash function. The hash function that vscode-jupyter uses for an interpreter is public (raw src/platform/pythonEnvironments/info/interpreter.ts, src/platform/telemetry/helpers.ts and src/platform/common/crypto.ts). getInterpreterHash takes the normalised interpreter path (getNormalizedInterpreterPath) and returns getTelemetrySafeHashedString of the path of that URI; that function is computeHash(data, 'SHA-256'), which encodes the text as UTF-8 (TextEncoder), takes its SHA-256 digest (Web Crypto) and writes each byte as two lower-case hexadecimal digits, so the value is 64 hexadecimal characters. The normalisation takes the file-system path of the interpreter and, on Linux and macOS only, when it ends in /bin/python and has more than four /-separated parts, replaces /bin/python by /python (so …/x64/bin/python and …/x64/python hash alike; /usr/bin/python is kept). A path is not lower-cased by getInterpreterHash. Not checked: the code that actually writes the value into the notebook’s metadata was not located, so this is the function the extension uses for interpreter hashes, assumed (not shown) to be the one behind metadata.vscode.interpreter.hash.
Jupytext
Sources: raw website/src/content/docs/formats/markdown.md, formats/scripts.md, using/paired-notebooks.md and reference/advanced-options.md of mwouts/jupytext. Notebook metadata jupytext (an object): formats (a string such as ipynb,md, set by pairing a notebook with text files); text_representation with extension (for example .md), format_name (for example markdown), format_version (a string such as 1.1) and jupytext_version; and optional settings such as cell_markers (for example "region,endregion" or """), split_at_heading (boolean), notebook_metadata_filter and cell_metadata_filter. By default the filters keep kernelspec,jupytext of the notebook metadata and all cell metadata except autoscroll, collapsed, scrolled, trusted and ExecuteTime, when writing text notebooks. In Jupytext’s Markdown format the same metadata sits under a jupyter: key of the YAML header.
Further keys, from the raw Jupytext source (src/jupytext/header.py, metadata_filter.py, cell_metadata.py). Inside the notebook’s jupytext object: executable (the #! line of a script, without the #!), encoding (the coding comment line of a script), root_level_metadata (YAML header keys of a text file that are not notebook metadata) and root_level_metadata_filter. Cell metadata Jupytext keeps to reproduce the text layout: cell_marker, lines_to_next_cell, lines_to_end_of_cell_marker, and the older skipline and noskipline. The source’s default notebook filter (_DEFAULT_NOTEBOOK_METADATA) keeps jupytext, kernelspec, kernel_info, orphan and tocdepth, and its default cell filter drops autoscroll, collapsed, scrolled, trusted, execution, ExecuteTime and the layout keys above; the documentation page lists a shorter set. The documentation names no complete list of the keys it writes, so the keys above are those the source read names.
Jupytext configuration options. The complete list of options of Jupytext’s configuration is the class JupytextConfiguration in src/jupytext/config.py (raw, mwouts/jupytext, main). These options are read from a configuration file (jupytext, jupytext.toml, jupytext.yml, jupytext.yaml, jupytext.json, each also with a leading dot, .jupytext.py, or pyproject.toml), not from the notebook; set_default_format_options copies the ones marked “format option” below into the options of a text format (setdefault, so an option already given for the format wins). The options, with their types and the help text of the source:
| Option | Type, default | Meaning (from the source’s help text) |
|---|---|---|
formats | text, list of text, list of dictionaries, or dictionary | Save notebooks to these extensions (any of ipynb, Rmd, md, jl, py, R, nb.jl, nb.py, nb.R, comma separated); append a format name as in ipynb,py:percent; a list of format dictionaries gives first-match pairing. |
default_jupytext_formats | text | Deprecated; use formats. |
preferred_jupytext_formats_save | text | Preferred format when saving as text, per extension, for example jl:percent,py:percent,R:percent. |
preferred_jupytext_formats_read | text | Preferred format when reading, per extension, for example py:sphinx. |
notebook_metadata_filter | text | Notebook metadata saved in the text representations (examples all, -all, widgets,nteract). Format option. |
default_notebook_metadata_filter | text, default empty | Deprecated; use notebook_metadata_filter. Format option (with a warning). |
hide_notebook_metadata | true, false or unset | Wrap the notebook metadata in an HTML comment in the Markdown format. Format option. |
root_level_metadata_as_raw_cell | boolean, default true | Whether root-level metadata of a text document (such as title or author of R Markdown) appears as a raw cell (true) or goes to the notebook metadata. Format option, copied only when false. |
root_level_metadata_filter | text | Notebook metadata promoted to the root level of the text representations (examples all, -all, kernelspec,jupytext). Format option. |
cell_metadata_filter | text | Cell metadata saved in the text representations (examples all, hide_input,hide_output). Format option. |
default_cell_metadata_filter | text, default empty | Deprecated; use cell_metadata_filter. Format option (with a warning). |
comment_magics | true, false or unset | Whether Jupyter magic commands are commented out in the text representation. Format option. |
split_at_heading | boolean, default false | Split Markdown cells on headings (Markdown and R Markdown only). Format option, copied only when true. |
sphinx_convert_rst2md | boolean, default false | When opening a Sphinx Gallery script, convert the reStructuredText to Markdown. Copied as rst2md, only when reading. |
doxygen_equation_markers | boolean, default false | Use the Doxygen format for equation markers. Format option, copied only when true. |
outdated_text_notebook_margin | number, default 1.0 | Refuse to overwrite the inputs of an ipynb notebook with those of a text notebook when the text notebook plus the margin is older (ignored by the command line tool). |
cm_config_log_level | warning, info, info_if_changed, debug or none; default info_if_changed | Log level for configuration-file messages in the Jupytext contents manager. |
cell_markers | text | Start and end cell markers of the light format, comma separated ({{{,}}} for Vim folds, region,endregion for VS Code and PyCharm regions). Format option, used when writing only. |
default_cell_markers | text | Deprecated; use cell_markers. Format option when writing (with a warning). |
notebook_extensions | list of text or text; default NOTEBOOK_EXTENSIONS (defined elsewhere in the source, not read) | A list of notebook extensions. |
custom_cell_magics | text | Comma-separated cell magics that are commented out in scripts (example configure,local). Format option. |
custom_language_magics | text | Comma-separated extra language magics whose Markdown code blocks become code cells with the cell magic (example jsx,tsx). Format option. |
Slideshow
Source: nbconvert/exporters/slides.py of jupyter/nbconvert, raw. Cell metadata slideshow.slide_type is one of slide, subslide, fragment, skip, notes, or - (the default when absent): slide starts a new slide (an HTML section), subslide a vertically stacked sub-slide (a nested section), fragment a div with class fragment inside a sub-slide, shown step by step. A - cell continues the current slide, sub-slide or fragment. The first cell whose type is not skip or notes always starts the first slide whatever its own type, and the last cell always ends a slide. If every cell is skip or notes the exporter refuses to make slides (“All cells are hidden, cannot create slideshow”). In nbconvert’s reveal.js template (share/templates/reveal/base.html.j2, raw) a notes cell is output inside an <aside class="notes"> element (speaker notes) and a skip cell is left out of the page. RISE (classic/rise/static/main.js, raw) reads the same slideshow.slide_type values (a missing or - value is a regular cell): it wraps notes cells in an <aside class="notes"> and hides skip cells.
RISE’s own settings can be stored in the notebook metadata under the key rise (RISE doc/customize.md, raw), for example "rise": {"theme": "serif", "transition": "zoom", "start_slideshow_at": "beginning"}; start_slideshow_at is beginning or selected (the default is the selected slide).
The settings that RISE’s doc/customize.md (raw, damianavila/RISE, master) documents for that rise object, all of them also settable through the nbextensions configurator or JSON configuration files, and in that order of precedence: notebook metadata first, then the configurator, then JSON files (rise.json):
| Key | Value and meaning, as documented |
|---|---|
theme | The reveal.js theme (for example sky, serif). |
transition | The transition between slides (for example zoom). |
autolaunch | Boolean: start the notebook immediately in slideshow view. |
start_slideshow_at | beginning (the first slide) or selected (the selected slide, the default). |
auto_select | Keeps the Jupyter selection in step with the slide: code (the first code cell is selected; the default), none or first (the first cell). Documented as experimental. |
auto_select_fragment | Boolean, default true: select cells by the current fragment; false selects by the slide as a whole. Experimental; ignored when auto_select is none. |
width, height | Slide size, as text such as "90%"; relative sizes are recommended, and pixel sizes are called dangerous. |
overlay | HTML or text wrapped in a <div>, a constant background; the author does all the styling. When it is set, header, footer and backimage are ignored. |
header, footer, backimage | HTML for a header and a footer, and an image file name for the background; minimal styling is applied. |
scroll | Boolean: a right scroll bar when the content is taller than the slide. |
enable_chalkboard | Boolean (from RISE 5.4.1): adds a chalkboard and a drawing layer; keys [, ], \, = and -. |
leap_motion | An object of reveal.js Leap Motion plugin options (naturalSwipe, pointerOpacity, pointerColor in the example), or the text "none" to disable. |
controls, progress, slideNumber, center, history | reveal.js settings that RISE passes through: the lower-right navigation arrows, the progress bar, slide numbers (boolean false turns them off), vertical centring and history. |
shortcuts | An object mapping RISE action names without the RISE: prefix (for example slideshow, edit-all-cells) to keys such as "alt-a"; a key given here replaces the default binding of that action. |
reveal_shortcuts | An object keyed by module (main, chalkboard) holding action names mapped to keys, for example {"main": {"toggleOverview": "tab"}}. The documented actions are firstSlide, lastSlide, toggleOverview, fullscreenHelp, riseHelp (main) and clear, reset, toggleChalkboard, toggleNotesCanvas, download (chalkboard). |
Older notebooks use the key livereveal for the same object; both are read, and rise wins if a setting is in both. Custom CSS is not a metadata key: RISE loads rise.css and <notebook name>.css from the notebook’s folder. The documentation also lists the Jupyter actions RISE registers (RISE:slideshow, RISE:smart-exec, RISE:toggle-slide, RISE:toggle-subslide, RISE:toggle-fragment, RISE:toggle-notes, RISE:toggle-skip, RISE:render-all-cells, RISE:edit-all-cells, RISE:rise-nbconfigurator).
Google Colab
Colab’s notebook metadata (a colab key, and cell keys such as id and colab_type) is not described: no public raw documentation or source from the Colab project defining the keys was found in this check, so none is asserted.