Technology & Developers
JSON Size Calculator
Paste or load JSON to see its exact size in bytes - as written, minified, pretty-printed and gzipped - and whether it is valid.
Free to useNo sign-up requiredNo watermarkRuns in your browser
API gateways, message queues, databases and serverless platforms all cap payloads in bytes, not characters. This calculator tells you exactly how many bytes your JSON takes up as UTF-8 - the encoding almost every API uses - along with what it would be minified, pretty-printed with a 2-space indent, and compressed with gzip.
It also validates the JSON and points to the line and column of the first syntax error, and can minify or re-format the text in place. You can paste JSON or load a .json file from your device; it is read and measured in your browser and never uploaded.
How this tool works
Paste or load your JSON
Paste into the box, or load a .json file from your device. The file is read locally.
Read the sizes
Raw UTF-8 bytes, minified, pretty-printed and gzip sizes update as you type.
Fix any errors
Invalid JSON is flagged with the line and column where the parser stopped.
Minify, format or download
Minify or format with 2 or 4 spaces, then copy or download the result.
How it works
The raw size is the number of bytes your text takes as UTF-8, exactly as pasted - including whitespace and line breaks. ASCII characters take 1 byte; accented letters and most other alphabets take 2; Chinese, Japanese, Korean and many symbols take 3; emoji take 4.
Minified and pretty sizes come from parsing the JSON with the browser’s own JSON engine and writing it back out with no whitespace, or with a 2-space indent. Because the output is re-serialised, escapes such as \u00e9 become the character itself and numbers such as 1.0 become 1, so these sizes can differ slightly from hand-edited text.
The gzip estimate compresses the minified JSON (or the raw text, if it is not valid) with the browser’s built-in CompressionStream and counts the output bytes. Servers may use different compression levels or Brotli, so treat it as a close estimate of what goes over the wire.
Common use cases
- Checking a request or response against an API gateway, load balancer or serverless payload limit.
- Estimating the size of messages sent to a queue, event bus or webhook with a byte limit.
- Seeing how much minification and gzip save before deciding whether to optimise an endpoint.
- Checking whether a document fits a database’s per-item or per-document size limit.
- Finding the exact line and column of a syntax error in a large JSON file.
JSON size vs UTF-8 bytes
Character count and byte count are the same only for plain ASCII. JSON text is almost always sent as UTF-8, where each character takes 1 to 4 bytes. JavaScript’s string length counts UTF-16 units instead, so an emoji counts as 2 there, 1 character to a person, and 4 bytes on the wire.
| A-Z, 0-9, { } " : , and other ASCII | 1 byte |
|---|---|
| é, ü, ñ, Greek, Cyrillic, Arabic, Hebrew | 2 bytes |
| €, Chinese, Japanese, Korean, Hindi, Thai | 3 bytes |
| Emoji and other characters outside the BMP | 4 bytes |
| \u00e9 escape sequence in JSON | 6 bytes (vs 2 for é itself) |
Formula
UTF-8 bytes
Σ bytes per character (1 for ASCII, 2-4 otherwise)
Minification saving
(raw bytes − minified bytes) ÷ raw bytes × 100
Worked examples
An API response close to a 6 MB limit
A pretty-printed 5.8 MB export minifies to about 4.1 MB, because indentation and line breaks often make up a quarter or more of formatted JSON. Gzip typically shrinks repetitive JSON like this to a small fraction of that again.
Characters vs bytes
{"city":"Zürich"} is 17 characters but 18 bytes, because ü takes 2 bytes in UTF-8. A 1,000-character Japanese string is about 3,000 bytes.
Frequently asked questions
Why is the byte size bigger than the character count?
Because your JSON contains non-ASCII characters. UTF-8 uses more than one byte for accented letters, non-Latin scripts and emoji, and payload limits are measured in bytes.
Which size does an API limit apply to?
Usually the bytes of the request body as sent - the raw or minified size, depending on what your client sends. Some limits apply after decompression and some before; check your provider’s documentation. When in doubt, compare the limit to the uncompressed size.
Is the gzip size exact?
It is a real gzip compression done by your browser, so it is close. Servers can use different compression levels, or Brotli, which usually compresses JSON a little smaller, so the size on the wire can differ somewhat.
Why is the minified size different from my own minifier?
This tool re-serialises the parsed JSON, which normalises escapes and number formats. Duplicate keys are also collapsed to the last value. A minifier that only strips whitespace can give a slightly different result.
Is my JSON uploaded anywhere?
No. Your JSON is processed locally in your browser and is not uploaded. Loaded files are read on your device, and there is no network request involved in measuring or compressing it.
