By Mian Ali Khalid · Published · How we build and test tools
How to use the json size
- Paste or type your JSON into the text area.
- The tool automatically parses the input using
JSON.parseto validate it. - Review the calculated byte size, character count, depth and element totals below.
- If the JSON is invalid, an error message points out exactly where parsing failed.
How JSON byte size is calculated
The json size in bytes depends on the character encoding used. This tool measures the length of the raw string when encoded as UTF-8, which is the standard for web APIs and most databases. ASCII characters (U+0000 to U+007F) take one byte each, characters from U+0080 to U+07FF take two bytes, U+0800 to U+FFFF take three bytes, and supplementary characters like emoji take four bytes.
For example, the JSON string {"cafe":"caf\u00e9"} contains 17 characters. The letter e with an acute accent (U+00E9) requires two bytes in UTF-8, making the total byte size 18. The character count counts Unicode characters (code points), so an emoji counts as one character even though it takes four bytes.
Depth and element counting rules
Nesting depth starts at 1 for the outermost container. A plain string, number, boolean or null has a depth of 1. An array inside an object pushes the depth to 2, and so on. The maximum depth tells you how deeply nested your data structure is, which matters for parsers that enforce recursion limits.
Total elements count every individual value in the tree: each key-value pair contributes the value as one element, each item in an array is one element, and a standalone primitive is one element. Keys themselves are counted separately so you can see how many properties exist across all objects in the document.
Why measure JSON payload size
Knowing the exact json size helps developers optimize network requests. REST APIs and GraphQL endpoints transmit data as JSON, and larger payloads consume more bandwidth and increase latency. Mobile clients on metered connections benefit from compact responses.
If you need to transform your data into another format, measuring the original size gives you a baseline. For instance, converting data with a json to xml tool typically increases the byte count because XML uses verbose opening and closing tags. Similarly, rendering data as a table via json to html table adds markup overhead. Comparing sizes before and after transformation helps you choose the most efficient serialization for your use case.
Common mistakes that inflate JSON size
Several habits silently bloat JSON payloads. Using overly long property names like userAccountEmailAddress instead of email adds bytes for every object in an array. Including fields with null values when the consumer treats missing keys as null wastes space. Deeply nested structures add extra braces and brackets that increase both byte size and parsing time.
Another common issue is embedding base64-encoded binary data directly in JSON. Base64 expands binary content by roughly 33 percent. If you frequently handle large blobs, consider sending them as separate multipart requests rather than inline strings. You can also inspect structural patterns using a json statistics tool to find redundant keys or unusually deep branches.
Reference table of typical JSON sizes
The following table shows approximate byte sizes for common JSON structures. Actual sizes vary based on property names and string lengths.
| Structure | Example | Approximate bytes |
|---|---|---|
| Empty object | {} | 2 |
| Empty array | [] | 2 |
| Single integer | 42 | 2 |
| Short string | "hello" | 7 |
| Boolean | true | 4 |
| Simple object (3 keys) | {"a":1,"b":2,"c":3} | 19 |
| Array of 5 integers | [1,2,3,4,5] | 11 |
Worked examples
| Example | Input | Result |
|---|---|---|
| Small object | JSON input: {"name":"Ada","age":36} | UTF-8 bytes: 23; Characters: 23; Type: object; Max depth: 1; Total elements: 3; Keys: 2 |
| Nested array | JSON input: [1,[2,[3,[4]]]] | UTF-8 bytes: 15; Characters: 15; Type: array; Max depth: 4; Total elements: 8 |
| Unicode text | JSON input: {"emoji":"\ud83d\ude00"} | UTF-8 bytes: 24; Characters: 24; Type: object; Max depth: 1; Total elements: 2; Keys: 1 |
| Empty object | JSON input: {} | UTF-8 bytes: 2; Characters: 2; Type: object; Max depth: 1; Total elements: 1 |
FAQ
What does json size mean?
It refers to the amount of storage or bandwidth a JSON string occupies, usually measured in bytes when encoded as UTF-8. It can also refer to the number of characters in the raw string.
Why is the byte count different from the character count?
Characters outside the basic ASCII range require multiple bytes in UTF-8 encoding. For example, an accented letter takes two bytes, and an emoji takes four bytes, even though each counts as one or two characters in JavaScript.
Does this tool upload my data?
No. Parsing and measurement happen entirely in your browser using JavaScript. Your JSON never leaves your device.
How is nesting depth calculated?
The outermost container is depth 1. Each time an object or array contains another object or array, the depth increases by one. A flat object with only primitive values has a depth of 1.
Can I check the size of minified versus pretty-printed JSON?
Yes. Paste either version into the tool. Pretty-printed JSON includes whitespace characters like spaces and newlines, which increase both the character count and the byte size.
What happens if my JSON is invalid?
The tool uses JSON.parse to validate input. If parsing fails, it displays the specific error message returned by the engine, including the position where the syntax broke down.