About the JSON to One Line
Collapse formatted JSON onto a single line for log entries, environment variables, curl commands and CLI arguments.
Key features
- Collapses formatted JSON onto a single line
- Removes all indentation and line breaks
- Validates the JSON while converting
- Perfect for env vars, logs and CLI arguments
- Preserves whitespace inside string values
- Instant and private
Why put JSON on one line?
Many systems treat a line as a unit: a log event, a shell argument, an environment variable or a CSV cell. Pretty-printed JSON spans many lines and breaks in those places. Converting it to a single line keeps it intact.
{
"service": "api",
"level": "info",
"port": 8080
}
becomes
{"service":"api","level":"info","port":8080}
Where one-line JSON is required
| Destination | Example |
|---|---|
| Environment variables | APP_CONFIG='{"debug":true}' |
curl request bodies | curl -d '{"q":"test"}' https://api… |
| Structured logging | One JSON event per line for Loki, ELK, Datadog |
| JSON Lines / NDJSON files | One record per line |
| CSV cells | A JSON column in a spreadsheet export |
| Docker / Kubernetes args | --config='{"x":1}' |
| GitHub Actions | fromJSON() inputs in a single-line variable |
Shell quoting tips
# bash / zsh: single quotes keep inner double quotes intact
curl -X POST -H "Content-Type: application/json" -d '{"name":"Ada"}' https://api.example.com/users
# PowerShell
Invoke-RestMethod -Method Post -ContentType 'application/json' -Body '{"name":"Ada"}' -Uri https://api.example.com/users
Related tools
Turn it back into readable JSON with JSON to Multi-line. Convert an array to one object per line with JSON to JSON Lines. For size savings statistics, use the JSON Minifier.
How to use the JSON to One Line
- Paste your data into the input box, upload a file, or click Sample to try it out.
- Adjust the options above the editor if you need to (indentation, delimiter, and so on).
- The One Line appears instantly in the output panel. Any errors are shown with their line and column.
- Click Copy to copy the result, or Download to save it as a file.