FracturedJson vs Standard JSON Formatting: Shorter, Cleaner Output
See how FracturedJson-style formatting keeps small arrays and objects on one line while expanding complex data, producing JSON that is shorter and easier to read.
- json
- formatter
- fracturedjson
The problem with standard pretty printing
Standard formatters, such as JSON.stringify(value, null, 2), apply one rule: every element goes on its own line. That works for deeply nested objects, but it wastes space on simple data.
Consider coordinates:
{
"points": [
{
"x": 1,
"y": 2
},
{
"x": 3,
"y": 4
},
{
"x": 5,
"y": 6
}
],
"origin": [
0,
0
]
}Twenty lines for six numbers. You have to scroll to see the shape of the data.
The FracturedJson approach
FracturedJson is a formatting algorithm that decides per element how much to expand. If a short array or object fits comfortably on a line, it stays on one line. Only complex or long content is broken across lines.
The same data:
{
"points": [
{ "x": 1, "y": 2 },
{ "x": 3, "y": 4 },
{ "x": 5, "y": 6 }
],
"origin": [0, 0]
}Eight lines, and every value is still visible without scrolling.
Table-style alignment
When consecutive items share the same structure, FracturedJson can line up their columns like a table:
{
"users": [
{ "id": 10, "name": "Ada", "age": 36 },
{ "id": 2, "name": "Grace", "age": 85 },
{ "id": 17, "name": "Linus", "age": 55 }
]
}Patterns jump out, and outliers are easy to spot.
Comparison
| Feature | Standard indent | FracturedJson style |
|---|---|---|
| Lines for small arrays | One per element | One line total |
| Aligned columns | No | Yes, for similar rows |
| Output length | Long | Much shorter |
| Diff friendliness | Good | Good with stable rules |
| Same parsed data | Yes | Yes |
Both produce identical data when parsed. Only whitespace differs.
When to use each
- FracturedJson style: reading data, reviewing API responses, documenting examples, config files with many small arrays.
- Standard indent: when a tool or team convention requires strict one-item-per-line output.
- Minified: when sending over the wire where size matters. See how to minify JSON.
Try it
NiceJSON formats with a FracturedJson-style layout by default. Paste any JSON, click Format, and compare the result with your usual output. You can still minify or expand it at any time, because only whitespace changes and your data is never altered.
Takeaway
Readable JSON is not about adding more whitespace. It is about putting whitespace where it helps. A layout that adapts to your data lets you understand structure in seconds instead of minutes.