From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "identification" |
|---|
| subject | "Format:Safetensors" |
|---|
| claim | "A safetensors file begins with a little-endian uint64 N (header size) followed by N bytes of UTF-8 JSON that starts with '{' (0x7B) and may be space-padded; the rest is the tensor byte buffer." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:Safetensors" |
|---|
| observed_in | |
|---|
|
|---|
| data | | method | "structure" |
|---|
| indicator | "bytes 0-7 = N (LE u64); N <= 100000000; bytes 8..8+N valid UTF-8 JSON, spec says it MUST begin with '{' (0x7B) but the reference reader leaves that to serde_json; 8 + N + size of the tensor buffer == file size (no holes, no trailing data)" |
|---|
|
|---|
| evidence | | type | "documentation" |
|---|
| detail | "Format section" |
|---|
| repo | "https://github.com/huggingface/safetensors" |
|---|
| commit | "e246a2560645b7525f5775669ed816eb57c5bcc8" |
|---|
| path | "README.md" |
|---|
| lines | "74-92" |
|---|
|
| type | "source" |
|---|
| detail | "MAX_HEADER_SIZE 100_000_000" |
|---|
| repo | "https://github.com/huggingface/safetensors" |
|---|
| commit | "e246a2560645b7525f5775669ed816eb57c5bcc8" |
|---|
| path | "safetensors/src/tensor.rs" |
|---|
|
| type | "source" |
|---|
| detail | "read_metadata: HeaderTooSmall below 8 bytes, u64 LE n, n > MAX_HEADER_SIZE (100_000_000) is HeaderTooLarge, header bytes must be UTF-8 and parse as JSON, then buffer_end + 8 + n must equal the buffer length or MetadataIncompleteBuffer. No separate '{' test." |
|---|
| repo | "https://github.com/huggingface/safetensors" |
|---|
| commit | "e246a2560645b7525f5775669ed816eb57c5bcc8" |
|---|
| path | "safetensors/src/tensor.rs" |
|---|
| lines | "389-425" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-18T18:14:11.362Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T09:27:48.475Z" |
|---|
| result | "confirmed" |
|---|
| method | "Downloaded safetensors tensor.rs at e246a256 and read read_metadata (390-425): LE u64 n, n > MAX_HEADER_SIZE rejected, header must be UTF-8 and JSON-parse, no explicit '{' test, buffer_end + 8 + n must equal the buffer length." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T09:16:31.188Z" |
|---|
| summary | "Read tensor.rs read_metadata: the reference reader does not test byte 8 for '{' itself (serde_json parses the header, so JSON whitespace first would parse), and it requires the whole file to be…" |
|---|
| changed | |
|---|
|
|
|---|