JSON Payload Size & Byte Budget Calculator

Inspect one JSON document as UTF-8 text. Compare original spacing, compact JSON and an indented form without passing numbers through a serializer. Find how much of the input comes from whitespace and how many separate identical document payloads fit in an entered byte budget. The worksheet runs in this page and keeps the source out of the metrics CSV.

UTF-8 JSON

Compare JSON bytes without changing values

Inspect original spacing, compact JSON and the chosen indentation against one payload budget.

Only Compact fits the entered copy count and byte budget.

As entered
76 bytes
14 layout whitespace bytes
Compact
62 bytes
0 layout whitespace bytes
Indented
88 bytes
26 layout whitespace bytes

Batch bytes against one budget

3 copies · black marker at the 200 byte budget.
As entered228 B

28 bytes over budget · at most 2 copies

Compact186 B

14 bytes remaining · at most 3 copies

Indented264 B

64 bytes over budget · at most 2 copies

  • JSON punctuation
  • Strings, numbers and literals
  • Layout whitespace
Open byte breakdown

Object · 17 significant tokens · depth 2 · 73 UTF-16 units · 72 code points.

BytesAs enteredCompactIndented
Per document766288
Punctuation101010
Literal and string bytes525252
Layout whitespace14026
Open compact and indented JSON
Show selectable metrics CSV

How to use this calculator

  1. Paste one valid JSON value into the local editor. Objects, arrays and individual JSON values are supported.
  2. Enter a payload byte budget, the number of identical copies to compare, and an indentation style.
  3. Compare bytes and maximum copies for the entered, compact and indented forms. Open the JSON text options when you need to copy either transformation.
  4. Use the metrics CSV to record the sizes and assumptions without including your source data.

The Formula

The mathematical logic powering this calculation is:

Count UTF-8 bytes from the supplied text. JSON punctuation marks are counted as structural bytes. Strings, names, literals and numbers retain their original token spelling and are counted as content bytes. Compact format removes only the JSON grammar's insignificant ASCII space, tab, carriage return and newline. Indented format reinserts spaces and line feeds around tokens without changing their order or spelling. The parser validates one JSON value. It does not use its parsed numeric values to produce either output. Escapes, duplicate name occurrences, numeric exponents, negative zero and numbers beyond JavaScript’s exact integer range therefore remain as supplied. RFC 8259 notes duplicate names can be interpreted differently by receivers.
Batch bytes = one payload bytes × entered identical copies. Remaining budget = entered budget − batch bytes. Maximum copies = budget divided by one payload size, rounded down. Copies are separate document payloads. No transport headers, delimiters, compression, surrounding array, BOM, newline framing or envelope are added. The textarea measures the text currently held in this editor; browser pasting can normalize line endings before the app receives it.
The input limit is 65,536 UTF-16 units and 64 nested array or object levels. Byte budget is 1–1,000,000,000 bytes and count is 1–1,000,000 copies. Raw unpaired UTF-16 is rejected; authored JSON escapes stay verbatim. Spaces within a quoted string always count as content. Code points and UTF-16 units are separate from bytes.

Worked Example

If you input:

  • JSON source: City Zürich, status 🌱, two numeric IDs
  • Budget: 200 bytes
  • Number of copies: 3
  • Indentation: Two spaces

Result:

The entered source is 76 UTF-8 bytes. Compact JSON is 62 bytes and indented JSON is 88 bytes. Three compact documents use 186 bytes and leave 14 bytes. Three entered documents use 228 bytes.

Frequently Asked Questions

Why are characters and bytes different?

UTF-8 uses one to four bytes for Unicode scalar values. A single visible character can also contain multiple code points or two UTF-16 units.

Will compacting round a long ID or change scientific notation?

The tool preserves numeric tokens exactly, even when a receiver would approximate the parsed result. The only edits are to structural whitespace.

What happens to whitespace inside a string?

It remains in the string token. A literal space, newline escape or tab escape keeps its bytes and spelling.

Is the compact value canonical JSON?

It keeps the entered object order, duplicate name occurrences and escape spellings. A canonical format may prescribe additional rules.

Do the totals include commas between payloads or compressed size?

The budget adds separately encoded document text only. Protocol framing and compression affect actual transfers and depend on the destination.

Does this send the source document anywhere?

The editor and its calculations run locally. The generated CSV records counts and labels; the two selectable text outputs contain your data.

Similar Calculators