NB (.nb)

Registered MIME types: application/mathematica, application/vnd.wolfram.mathematica
Wolfram System notebooks.
Used for storing and exchanging Wolfram Language input and output and for the creation of interactive technical documents.
Native file format of the Wolfram System notebook interface.
ASCII format based on the Wolfram Language expression syntax.
Stores text, typeset expressions, graphics, animations, sounds, and other Wolfram Language input and output.
Supports interactive elements like hyperlinks, buttons, sliders, and other graphical user interface features.
Uses external or embedded stylesheets for specifying the appearance onscreen and in print.
Developed since 1988 by Wolfram Research.
  • Import and Export fully support the Wolfram System notebook format.

Import and ExportImport and Export

  • Import["file.nb"] reads a Wolfram System notebook and returns it as a Notebook expression.
  • Export["file.nb",expr] exports a Notebook, Cell, or box expression, as well as arbitrary mathematical expressions as a notebook.
  • Import["file.nb",elem] imports the specified element from a notebook.
  • Import["file.nb",{elem,suba,subb,}] imports a subelement.
  • Import["file.nb",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","NB"] or Import["file",{"NB",elem,}].
  • Export["file.nb",expr,elem] creates a notebook by treating expr as specifying element elem.
  • Export["file.nb",{expr1,expr2,},{{elem1,elem2,}}] treats each as specifying the corresponding .
  • Export["file.nb",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.nb",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • Put[expr1,expr2,,"file.nb"] can be used to export multiple expressions.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the notebook format.

Notebook InterfaceNotebook Interface

  • In the notebook front end, Save and Save As can be used to save the current notebook to a file.

ElementsElements

  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Import elements:
  • "Cells"list of cell styles
    "Initialization"reads and evaluates all initializaton cells, returning the results as a list
    "Notebook"notebook represented as a Notebook expression
    "NotebookObject"NotebookObject expression
    "Plaintext"plain text version of the notebook
  • Import by default uses the element for notebook files.
  • The following can be used to select cells based on cell style:
  • "Cells"list of cell styles
    "Cells",styleall cells of style style

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Show the Import elements available in a sample file:

In[1]:=
Click for copyable input
Out[1]=

Convert an arbitrary mathematical expression to the notebook format:

In[1]:=
Click for copyable input
Out[1]=

Import plain text contents from the previous output:

In[2]:=
Click for copyable input
Out[2]=

Import all input cells from the sample file:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 1999
(4.0)
| Updated in 2007
(6.0)