Skip to content
XUtilHub

JSON to One Line Converter

Convert multi-line JSON into a single line. Perfect for logs, environment variables and command-line arguments.

  • Free, no sign-up
  • Runs in your browser, nothing uploaded
Input
Output

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

DestinationExample
Environment variablesAPP_CONFIG='{"debug":true}'
curl request bodiescurl -d '{"q":"test"}' https://api…
Structured loggingOne JSON event per line for Loki, ELK, Datadog
JSON Lines / NDJSON filesOne record per line
CSV cellsA JSON column in a spreadsheet export
Docker / Kubernetes args--config='{"x":1}'
GitHub ActionsfromJSON() 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

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

  1. Paste your data into the input box, upload a file, or click Sample to try it out.
  2. Adjust the options above the editor if you need to (indentation, delimiter, and so on).
  3. The One Line appears instantly in the output panel. Any errors are shown with their line and column.
  4. Click Copy to copy the result, or Download to save it as a file.

Frequently asked questions

Is this the same as minifying?

Yes, the output is identical to minified JSON. This page focuses on single-line use cases like environment variables and command lines.

How do I pass one-line JSON in a shell command?

Wrap it in single quotes in bash/zsh: curl -d '{"a":1}' .... In Windows PowerShell, use single quotes too, or escape inner double quotes in cmd.exe.

Can I put this JSON in a .env file?

Yes. Most dotenv parsers accept JSON wrapped in single quotes: CONFIG='{"debug":true}'. Then call JSON.parse(process.env.CONFIG).

Why do log systems prefer one-line JSON?

Log shippers treat each line as one event. Multi-line JSON would be split into broken fragments; single-line JSON (NDJSON) stays intact.

Is my JSON uploaded to a server?

No. All JSON tools run entirely in your browser, so your data never leaves your device.

Is there a size limit?

There is no fixed limit. Files of several megabytes work fine; very large files depend on your device's memory.

Do I need an account?

No. Every JSON tool is free and works without signing up.

Last updated:

Related JSON tools