JSON to One Line
Collapse JSON to a single line for logs, env vars and inline config — readable spacing or fully compact, big numbers preserved exactly, entirely on this device.
Collapsing to one line changes whitespace only — never key order, never values.
Press ? for shortcuts
Do it offline:$ jq -c . file.json
How to use it
- Paste JSON, or drop a .json or .txt file up to 50 MB; under 2 MB it updates live, and past that a button names the size before running.
- Choose Spaced for the readable line or Compact for the smallest one-liner; the Separators choice is remembered next visit.
- Malformed JSON emits nothing: the message pins the line, column and likely cause, a caret frame marks the spot, and your text stays put.
- Copy the finished line, save it as a .json file, or Share a link carrying only the input you included.
Paste formatted JSON and it collapses onto a single line you can drop into a log message, an environment variable, or an inline config field. The default keeps a space after every colon and comma so the line stays readable; one toggle switches to fully compact. Key order, string contents, and long integers all arrive exactly as written, and the conversion runs on this device.
Examples
{
"level": "info",
"service": "auth-api",
"replicas": 3,
"flags": { "beta": true, "trace": false },
"regions": ["us-east", "eu-west"]
}{"level": "info", "service": "auth-api", "replicas": 3, "flags": {"beta": true, "trace": false}, "regions": ["us-east", "eu-west"]}The document folds onto one line with a space after each colon and comma, so it reads cleanly in a log entry or shell variable.
{"level": "info", "service": "auth-api", "replicas": 3, "flags": {"beta": true, "trace": false}, "regions": ["us-east", "eu-west"]}{"level":"info","service":"auth-api","replicas":3,"flags":{"beta":true,"trace":false},"regions":["us-east","eu-west"]}Paste that result back and flip to Compact: the separator spaces vanish and what remains is byte-for-byte what the JSON Minifier emits for the same document.
{"traceId":1802074880000000513,"raw":"login:ok,cached","enc":"caf\u00e9","lit":"café"}{"traceId": 1802074880000000513, "raw": "login:ok,cached", "enc": "caf\u00e9", "lit": "café"}The spacing here is purely structural: the 19-digit trace id keeps every digit, the inner colon and comma stay glued, the \u00e9 escape stays escaped, and the literal é stays literal.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
Spaced, compact, and how this differs from minify
Spaced leads because a log line reads better with a space after each separator. Compact drops them and returns the same bytes the JSON Minifier produces, so the page is two outputs behind one control.
Commas and colons inside strings are never touched
A space is added only after a colon or comma between tokens. Punctuation inside a string is copied unchanged, so a value like "login:ok,cached" survives intact while the separators around it gain spaces.
Every digit of a big number survives
Numbers are never parsed to a float and printed back — the exact step where integers past 2^53 lose their last digits. A snowflake id, a nanosecond timestamp, or a literal such as 1E+2 survives as pasted.
Already one line — an honest no-op
Convert a document already single-line in the current mode and the status says nothing changed, never inventing a saving. The check is byte-level: a spaced line re-run spaced reports no change, as does a compact line left compact.
The size ladder up to 50 MB
Under 2 MB conversion runs on each keystroke; from 256 KB it moves to a background thread; from 2 MB a button holds the run until pressed. Above 50 MB the input is declined for the command line, since reshaping a slice yields a different document.
Common errors
Unexpected ']' at line 1, column 18 — probable cause: trailing comma after the last element.- A comma announces one more element, so the closing bracket arrives with nothing after it. Delete the last comma and the line converts.
Unexpected "'" at line 1, column 10 — probable cause: single-quoted strings are JSON5, not JSON; use double quotes.- Single quotes are fine in JavaScript and JSON5, but RFC 8259 recognises only double-quoted strings. Swap them and the value parses; rejected input yields no output.
Unexpected 's' at line 1, column 2 — probable cause: property names must be double-quoted.- YAML and JavaScript allow bare keys; JSON insists on quotes around every property name. Wrap the key in double quotes and convert again.
Unexpected end of input at line 1, column 20 — probable cause: the document is incomplete or truncated.- An opening bracket or brace was never closed — a clipped clipboard, a length-limited log column, or a half-finished paste. Restore the tail; a fragment on one line is still a fragment.
This tool streams up to 50MB; beyond that, try the CLI: jq -c . file.json- Past 50 MB the input is refused rather than reshaped in part, and your text stays put. jq handles a file that size locally; note that jq -c produces the compact form, matching the Compact toggle rather than the spaced default.
FAQ
How is this different from the JSON Minifier?
The Minifier always removes every insignificant space; this tool keeps a space after each colon and comma by default, which keeps a one-line log entry or .env value readable. Flip Separators to Compact and the output is byte-identical to minify.
Does going to one line change my data?
No. Only whitespace between tokens is added or removed; keys keep their order, strings keep their contents, and numbers keep every digit. Each worked example above is executed against the live engine at build time, so the printed pairs cannot drift.
Which should I use for logs or .env files?
Use Spaced. One readable line pastes cleanly into a log message, a shell export, or a JSON string field. Reach for Compact only when a byte budget or a single-token field forces the separators out.
Why is my output longer than the input?
Spaced mode adds a space after every structural colon and comma, so an already-compact document returns slightly larger. It is a reshape, not a size optimisation, which is why no saved percentage is ever shown; use Compact for the shortest line.
Keyboard shortcuts
- ⌘/Ctrl + Enter
- Convert now — required once a paste passes 2 MB, and a manual re-run below that.
- ⌘/Ctrl + S
- Save the one-line output as a .json file, replacing the browser's save shortcut here.
- ⌘/Ctrl + C
- With the tool focused and no selection, copy the whole output line; a highlighted span copies instead.
- ⌘/Ctrl + Shift + C
- Copy the full one-line output whether or not anything is selected.
- t
- Toggle the colour theme, unless a text field is focused or an IME composition is running.
- ? or ⌘/Ctrl + /
- Open the keyboard-shortcut help dialog, listing the browser-conflict caveats.
- Esc
- Close the frontmost dialog; your input is left exactly as it was.