NB

application/mathematica

Safe

Magic Bytes

Offset: 0
28 2A 2A

The Wolfram Notebook (NB) is a proprietary file format developed and maintained by Wolfram Research for use within the Mathematica ecosystem. This format serves as an interactive document for mathematical computation, data visualization, and literate programming, containing both executable code and formatted results. While inherently safe as a text-based storage format, notebooks can include dynamic content that may pose risks if executed from untrusted or unverified sources.

Extension

.nb

MIME Type

application/mathematica

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .nb files in Python

Python
def is_nb(file_path: str) -> bool:
    """Check if file is a valid NB by magic bytes."""
    signature = bytes([0x28, 0x2A, 0x2A])
    with open(file_path, "rb") as f:
        return f.read(3) == signature

How to validate .nb files in Node.js

Node.js
function isNB(buffer: Buffer): boolean {
  const signature = Buffer.from([0x28, 0x2A, 0x2A]);
  return buffer.subarray(0, 3).equals(signature);
}
Go
func IsNB(data []byte) bool {
    signature := []byte{0x28, 0x2A, 0x2A}
    if len(data) < 3 {
        return false
    }
    return bytes.Equal(data[:3], signature)
}

API Endpoint

GET /api/v1/nb
curl https://filesignature.org/api/v1/nb

Related Formats