JSON to PHP & JS Converter — developer utilities, encoders and data format tools
Instantly convert JSON into a PHP array or a JavaScript object literal, with syntax-safe escaping for quotes and backslashes.
Category: Developer Tools
About this tool
What Is the JSON to PHP and JavaScript Converter? This tool takes JSON text and converts it directly into a PHP array you can paste into your code, or into a JavaScript object constant. It saves you from typing brackets, commas and string escapes by hand, especially for nested data. How to Use It Paste your JSON text into the input box. Choose the target: a PHP array or a JavaScript object. Press the convert button. Copy the result from the output box. What the Output Looks Like PHP: an array in key then value form, indented by four spaces per nesting level. PHP: strings wrapped in single quotes, with backslashes and single quotes escaped inside the text. PHP: booleans pass through as true and false, an empty value passes as null, and numbers are written without quotes. JavaScript: a constant that starts with const data and ends with a semicolon, with the object pretty printed. Important Notes The text is read with a standard JSON parser, so any mistake in commas or brackets produces an error message. An empty JSON object comes out as an empty array, because the converter has no separate syntax for an empty map. The tool does not convert from PHP to JSON and does not read files or URLs. Related Tools JSON Formatter — tidy and reformat JSON text. JSON Validator and Formatter — check the syntax before converting. YAML Formatter — convert to YAML. XML Formatter — convert to XML. F