imports cells with the given cell style from the specified notebook.


imports cells in the form specified by form.

Details and Options

  • In NotebookImport[notebook,], notebook can be a NotebookObject, a file name, a CloudObject corresponding to a notebook, or a Notebook expression.
  • If style is a pattern, cells whose style matches that pattern are imported. A typical pattern is "name1"|"name2"|, indicating to import any of the styles namei.
  • If style is _, all cells are imported.
  • Possible values for form include:
  • "Boxes"first argument of low-level cell expression
    "Cell"complete low-level cell expression
    "Expression"cell converted to an expression
    "HeldExpression"cell converted to a held expression
    "HeldInterpretedCell"cell converted to a held TextCell or ExpressionCell
    "Hyperlinks"list of hyperlinks in the cell
    "InactiveExpression"cell converted to an inactive expression
    "InputText"cell contents as given by Copy As Input Text
    "InterpretedCell"cell converted to a TextCell or ExpressionCell
    "Text"cell contents as given by Copy As Plain Text
  • The following options can be given:
  • "FlattenCellGroups"Truewhether to flatten nested lists corresponding to the cell group hierarchy
    "StyleImportRules"Automaticspecify forms to return for different cell styles
  • With the setting "FlattenCellGroups"->False, one level of list will be present for every cell group in the notebook, whether or not any cells were imported from that group.
  • The setting "StyleImportRules"->Automatic is equivalent to the following mappings:
  • "Title""Text"
  • "Text"
  • "Subchapter"
  • "Text"
  • "Section"
  • "Text"
  • "Subsection"
  • "Text"
  • "Subsubsection"
  • "Text"
  • "Text"
  • "Text"
  • "Code""Cell"
  • Other styles are given in "Boxes" form.


open allclose all

Basic Examples  (1)

Create a notebook:

Import the cells in this notebook to the default forms:

Import cells in this notebook as a list of text strings:

Import only Input style cells, as held expressions:

Import input cells as evaluatable text:

Import input cells as inactive expressions:

Import all input and output cells from a notebook, preserving cell grouping information:

Import evaluatable text for every input and output cell:

Scope  (5)

Import from a notebook file:

Import from a Notebook expression:

The "InterpretedCell" form results in a list of TextCell and ExpressionCell expressions, as appropriate:

The "HeldInterpretedCell" form returns held expressions:

The "Cell" form returns expressions appropriate for use in low-level notebook operations, like NotebookPut:

The "Hyperlinks" form returns a list of Hyperlink expressions imported from each cell:

Options  (3)

"FlattenCellGroups"  (2)

Import a nested textual representation of some of the cells in a notebook:

Import a nested textual representation of all the cells in a notebook:

"StyleImportRules"  (1)

Specify different forms for different cell styles:

Possible Issues  (2)

Cells that contain an incomplete expression will fail when imported to an expression-based form:

HoldComplete affects only evaluation, not typesetting:

Use InputForm to see the untypeset form of the returned expressions:

String-based forms are inert to evaluation and most typesetting:

Neat Examples  (2)

Import historical information from a function's reference page:

Import the list of symbol names in the See Also links of a reference page:

Wolfram Research (2015), NotebookImport, Wolfram Language function,


Wolfram Research (2015), NotebookImport, Wolfram Language function,


@misc{reference.wolfram_2020_notebookimport, author="Wolfram Research", title="{NotebookImport}", year="2015", howpublished="\url{}", note=[Accessed: 02-December-2020 ]}


@online{reference.wolfram_2020_notebookimport, organization={Wolfram Research}, title={NotebookImport}, year={2015}, url={}, note=[Accessed: 02-December-2020 ]}


Wolfram Language. 2015. "NotebookImport." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2015). NotebookImport. Wolfram Language & System Documentation Center. Retrieved from