What is the NB file format?
.nb is a file format associated with Mathematica software developed by Wolfram Research. Rather than a simple output file, a .nb notebook is a live computational document that mixes executable code, formatted results, typeset mathematics, and rich media in a single file. .nb files can contain images, audio data, mathematical functions, or references to external resources. .nb files store information in plain text as a top-level Notebook[] Wolfram Language expression, with content organized into nested Cell[] objects - input cells, output cells, text cells, and section headings. .nb data can be accessed interactively using the Mathematica notebook viewer; that data can be edited and manipulated.
Mathematica can be used to perform advanced mathematical computations. It supports such data as images, graphs, or audio data. Mathematica can generate such structures as fractals based on equations, or calculate audio signal correlations. .nb notebooks can be exported to other formats, including PDF, HTML, LaTeX, and CDF. DefaultStyles.nb is a built-in notebook that defines the default cell styles applied to new notebooks; it ships with Mathematica as a style template rather than as the format specification itself. Related Wolfram text-based formats include .wl for pure Wolfram Language scripts and .m for legacy package files.
Security & safety
RISK: MEDIUMA notebook can contain executable Wolfram Language code, and evaluating cells can run arbitrary operations (file access, network, system calls). Opening an .nb to VIEW it (especially in Wolfram Player) is safe; the risk is RUNNING code from an untrusted notebook. Treat an unfamiliar .nb like a script: read the input cells before evaluating, and don't blindly Shift+Enter through a notebook from an unknown source. The plain-text format makes inspection easy.
Format details
in a nutshellPrograms that open NB files
Technical details
deep spec| MIME type | application/vnd.wolfram.mathematica (also application/mathematica for older files) |
| Text encoding | UTF-8; legacy files use ASCII with \[Name] escape sequences for Unicode and special characters |
| File structure | Single top-level Notebook[] expression containing an ordered list of Cell[] objects, each tagged with a style name such as Input, Output, Text, Title, or Section |
| Compression | None at file level; embedded raster images and large graphics are stored as base64 or PackedArray data inside cell expressions |
| Cell types | Input (code), Output (cached results), Text, Title, Chapter, Section, Subsection, Print, Message - organized into collapsible CellGroup[] sections |
| Typical file size | 10 KB to several MB; size grows significantly when notebooks cache output graphics or embed high-resolution images |
| Live interactivity | Code cells evaluate against a running Wolfram kernel; output is cached in Output cells and remains visible without a kernel for static reading |
| Notebook locking | Optional player-locked variant (.nbp) created via Encode[]; restricts editing while allowing Wolfram Player to execute the notebook |
| Platform support | Windows, macOS, Linux via Wolfram Mathematica (full authoring) and Wolfram Player (free, run-only); also available via Wolfram Cloud in a browser |
| Evaluation language | Wolfram Language (formerly Mathematica Language); all code cells are Wolfram Language expressions evaluated by a connected kernel |
| Export formats | PDF, HTML, TeX/LaTeX, CDF, PNG, SVG, EPS, Markdown, and plain text via Export[] or File > Save As |
| Version compatibility | Forward- and backward-compatible across Mathematica versions; format version is declared in the file header and newer constructs are feature-gated |
| File identification | No binary magic bytes; identified by the plain-text header comment (* Content-type: application/vnd.wolfram.mathematica *) on the first line |
| Related formats | .wl and .wls (Wolfram Language scripts), .cdf (Computable Document Format), .m (legacy package), .mx (binary serialized expression dump) |
| Released | 1988 (Mathematica 1.0) |
| Latest version | Wolfram Notebook format tracks the app (Mathematica 14.x / Wolfram Language 14, 2024-2025) |
| Specification | reference.wolfram.com |
NB conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about NB files.