Skip to content
StringToJSON

String to JSON — Online Converter

Convert any string to JSON, online and instantly.

Paste an escaped string, a stringified log line, or a double-encoded webhook body. Get formatted, validated JSON back — free, private, nothing uploaded.

Escaped string

0 B

JSON

0 B

Output appears here.

Ready. Paste something above.

Everything runs locally in your browser — your data never leaves this page. Press⌘/Ctrl +Enter to run.

Built for the strings that actually show up.

  • Handles double-encoded payloads

    Logs and message queues often hand you JSON that was stringified twice. The parser unwraps each layer until it reaches real structure.

  • Exact error coordinates

    When parsing fails you get the line, the column and a jump-to-error button — not a vague "unexpected token" and a shrug.

  • Nothing leaves your machine

    No upload, no request, no logging. The whole converter is a few kilobytes of JavaScript that runs in your tab, offline included.

Before → after

One paste, one pass, done.

The kind of line you pull out of CloudWatch or a Kafka topic — quoted, escaped, and impossible to read — becomes an indented document you can actually scan.

Try it above

// input

"{\"level\":\"warn\",\"msg\":\"retry\",\"attempt\":3}"

// output

{
  "level": "warn",
  "msg": "retry",
  "attempt": 3
}

How to convert a string to JSON online.

  1. 01

    Paste your string

    Drop it into the left pane, upload a file, or drag one in.

  2. 02

    Pick your indent

    2 spaces, 4 spaces, tabs, or minified. Sort keys if you need a stable diff.

  3. 03

    Copy the result

    Copy to clipboard or save it as a .json file. Nothing is uploaded either way.

What this string to JSON converter online does

A string that contains JSON is not the same thing as JSON. Somewhere between the service that produced your data and the terminal you are reading it in, the document got serialized into a single line, its quotes escaped to \" and its newlines flattened to \n. What you have left is technically correct and completely unreadable.

This free online string to JSON converter reverses that. Paste the escaped string, the quoted literal, or the raw line you copied out of a log, and it parses the text back into a real value and prints it indented and syntax-highlighted. If the payload was stringified more than once — the usual case for webhook envelopes and message-queue bodies — each layer is unwrapped in the same pass, so you do not have to convert the string to JSON twice by hand.

Where this comes up

  • A log line where an entire API response was written into one field.
  • A database column that stores a serialized payload as text.
  • A webhook that base64- or string-encodes its body inside an envelope.
  • A JavaScript JSON.stringify result pasted into a bug report.
  • An environment variable holding a whole configuration document.

What you get back

Formatted JSON at your choice of indentation — two spaces, four spaces, tabs, or minified — with optional recursive key sorting for a stable diff. The status bar names the top-level type, counts the keys and reports the nesting depth, so you can confirm the shape without reading the whole document. When the input is not valid, you get the reason plus the exact line and column, and a button that puts your cursor on the offending character.

Need the opposite direction? The JSON to string converterescapes a document back into a single literal. For other formats, there isBase64 to JSON, XML to JSON andJSON to CSV.

The same job, a dozen different names

People arrive here searching for all sorts of things — str to json,convert string to json online, parse string to json,json string to json online, transform string to json,json string to object, string to json online converter,string to json online tool, format string to json online,convert comma separated string to json online,multiline string to json online, convert json string to json online, and string to json online editor. They are all the same operation, and this page does all of them. Whether your input is called a stringified payload, an escaped literal, a serialized document or just "that unreadable line from the log", the conversion is identical: parse the text, then print the value.

One distinction is worth drawing, because it trips people up. Convert json string to json object and string to json array online describe the same tool, not two — what you get back depends entirely on what the top-level value in your data happens to be. A payload wrapping an object gives you an object; one wrapping a json string array gives you an array. The status bar names the type it found, so you never have to guess which one you are holding.

Need to convert string to JSON in a specific language? Use thePython,JavaScript,Java,C#,PHP, orGo guides — each one embeds this same online converter alongside language-specific code examples.

Why it runs in your browser

The data people paste into a converter is rarely synthetic. It is a real response with real customer names in it, a log line from production, an auth payload copied out of a debugger. Sending that to someone else's server to be pretty-printed is a poor trade, and it is an unnecessary one: browsers have shipped a fast, spec-compliant JSON parser for over a decade.

So there is no backend here. The conversion is a few kilobytes of JavaScript using the native JSON.parse and JSON.stringify — the same implementation your own application will use, which means a payload that converts here will parse there. Open your network tab while you use it and you will see no requests at all. Disconnect from the internet and it keeps working.

Valid JSON, in one place

Most conversion failures come down to the same short list of rules, so it is worth having them somewhere you can check quickly.

  • A document is a single value: an object, an array, a string, a number,true, false or null.
  • Keys are double-quoted strings. Not single-quoted, not bare.
  • No trailing comma after the last element of an object or array.
  • No comments — neither // nor /* */.
  • NaN, Infinity and undefined do not exist. Usenull or a string.
  • Inside a string, escape ", \ and every control character — a literal newline or tab is invalid.
  • Numbers use decimal notation: no leading +, no leading zeros, no hex.

Anything violating one of these is a JavaScript object literal, JSON5 or JSONC — all useful formats, none of them JSON. Thevalidator names the rule you broke and points at the character.

Convert string to JSON in your language.

Every language spells this differently, and each one has its own way to go wrong. These guides cover the idiom, the round trip, and the errors you will actually hit — Python, JavaScript, Java, C#, PHP, Go, and SQL.

Frequently asked questions

How to convert a string to JSON?
Paste the string into the left pane of this converter. It parses escaped, quoted, or double-encoded text and prints formatted JSON. Conversion runs as you type; ⌘/Ctrl + Enter re-runs it. Choose 2-space, 4-space, tab or minified indent, then copy the result or save a .json file. Nothing is uploaded.
How to convert a JSON string to a JSON object?
A JSON string is text that contains JSON — often wrapped in extra quotes with escaped inner quotes like "{\"id\":1}". Paste it here and the converter unwraps it into a real object (or array). In code the same job is JSON.parse in JavaScript, json.loads in Python, Jackson or Gson in Java, and JsonSerializer.Deserialize in C#.
How to convert JSON to a string?
Use the JSON to string converter to minify and escape a document into a single-line literal. In code: JSON.stringify(obj) in JavaScript, json.dumps(obj) in Python, mapper.writeValueAsString(obj) in Java, JsonSerializer.Serialize(obj) in C#.
How to convert a JSON object to a string?
Serialize the object. Online, paste it into the JSON to string tool. In JavaScript that is JSON.stringify; in Python json.dumps; in Java writeValueAsString or Gson toJson; in C# JsonSerializer.Serialize. Do not concatenate the object into a template — that produces [object Object].
How to remove escape characters from a JSON string?
Paste the escaped string into this converter — it unescapes \", \n, \t and nested layers automatically. For arbitrary text that is not valid JSON, use the JSON unescape tool. In code, parse once (JSON.parse / json.loads) to strip one layer of escaping.
How to convert a JSON string to an object?
Same conversion as string to JSON: parse the text. This page does it in the browser. A payload whose top-level value is an object comes back as an object; one whose top-level value is an array comes back as an array. The status bar names the type so you can confirm the shape.
How to pass a variable in a JSON string?
Do not splice values in with string concatenation — a quote in the value will break the document. Build an object, assign the variable as a property, then serialize: JSON.stringify({ id, name }) in JavaScript, or json.dumps({"id": id, "name": name}) in Python. That is the only way that always escapes correctly. See also how to pass a variable in a JSON string in Python.
How to convert a string to JSON in Python, Java or C#?
Python: json.loads(text) — see the Python guide. Java: Jackson readValue, Gson fromJson, or new JSONObject(text) — see the Java guide. C#: JsonSerializer.Deserialize<T>(json) — see the C# guide. Use the converter above to check the payload first.
Is my data sent to a server?
No. There is no backend. Every conversion happens in your browser with the native JSON.parse and JSON.stringify, and the page keeps working with the network disconnected. Your last input is stored in localStorage on your own device — clearing the field removes it.
Why does JSON with trailing commas or single quotes fail?
Those are JavaScript object-literal conventions, not JSON. RFC 8259 requires double-quoted keys and forbids trailing commas. The validator points at the exact offending character.