To pretty-print JSON from logs, copy only the JSON value. Delete the timestamp, log level, process id, and any PHP or Magento notice that printed before the first { or [. Paste what remains into the JSON Validator. If it is valid, paste the same string into the JSON Formatter and choose Format. If it is invalid, fix the first token. Do not format first.
Minified API responses follow the same order. The body is often already legal JSON. It is unreadable because it has no whitespace, not because it is broken. Validate, then format. That is how you pretty-print JSON from logs and from APIs without guessing.
A log line is a record, not a JSON document. Typical prefixes:
2026-09-24T09:12:01Z ERRORef bb bf if the file was saved from a Windows editorThe validator fails at position 0 when any of that is still attached. People then blame the formatter. The formatter never saw JSON. It saw ERROR {"user": or Notice: … {"order":.
API clients add a different kind of junk: a wrapping string that was escaped twice ("{\"id\":1}"), or HTML from an error page when the endpoint returned 500 with a body that is not JSON at all. Treat those as different jobs. This guide is for a line that is supposed to contain one JSON value.
{ or [. If the value is a JSON string, number, true, false, or null, there is no brace — copy the token the logger stored, not the whole line."{" and contains \" is a string, not an object. Unescape once, then validate the inner text.Do not run a regex that “grabs everything between the first brace and the last.” Nested objects and braces inside strings will lie to you. Prefer copying the field the logger named (body=, payload=, context=) when the format is structured.
Paste the isolated string into the validator. Empty input is not JSON. A trailing comma, a single-quoted key, or a comment means you isolated a JavaScript dump, not JSON. Convert that dump with the object-literal guide, then come back here.
When validate reports a valid object or array, format it. Indentation is for you, not for the server. If you will send the body again, minify after you finish reading — a pretty-printed body is a different artifact than the log field you started with. The order matches format, validate and minify JSON.
YallaSolve does not upload the payload for these tools. The string still lives in the tab. Do not paste live tokens into a shared machine and walk away.
Log line
2026-09-24T09:12:01Z ERROR checkout id=881 body={"user":{"id":12,"name":"Ada"},"total":19.5}
Copy from the first { through the last }. Validate: valid object. Format: you can see user and total. If total is the bug, you found it because you could read the tree, not because you stared at one line.
Minified API body
{"items":[{"sku":"A1","qty":2},{"sku":"B2","qty":1}],"ok":true}
No prefix. Validate: valid. Format: the two line items are obvious. You do not minify this unless you are putting it back on the wire.
Escaped twice
"{\"ok\":true,\"n\":2}"
This is a JSON string whose content is JSON. Paste it as-is and validate: you get a string, not an object. Remove the outer quotes and unescape \" to ", then validate again. Now format. If you format the outer string, you only pretty-print a quoted blob and still cannot see ok.
WordPress, Magento, and some PHP loggers json_encode a value and then interpolate it into another JSON envelope or a quoted log field. You will see backslashes in front of every quote. Decode one layer at a time. After each layer, validate. Stop when the validator reports an object or array you recognize, or when a layer is plain text.
If validate never succeeds, the field is not JSON. It may be print_r, a stack trace, or HTML. Do not keep hitting Format. Open the parse-error solution for the token you have, or rebuild the payload from the application.
Pretty-print is a reading step. It does not fix production. Once you can see the structure, decide whether the bug is a bad value, a missing key, or a wrap you should not have logged. Then delete the formatted copy if it contains customer data.
The timestamp, level, or notice is still attached. Copy from the first { or [ and validate that slice.
No. A log file is a sequence of records. Isolate one field, validate, then format that value.
The payload was escaped and wrapped in quotes. Unescape one layer and validate again before you format.
Format only adds insignificant whitespace after a successful parse. If you need the compact body again, minify after you finish reading.
Copy from the first { or [ only. A notice, timestamp, or HTML error page is not part of the value. Validate that slice before you format.