We use cookies.This website uses essential cookies to operate core features. With your consent, we also use analytics cookies to understand traffic and improve the service. For more details, see our .
Was this tool helpful to use?
Your feedback helps us make it better
Quickly convert JSON data into ready-to-use PHP array code. Perfect for API integration and configuration migration.
Overview
Understand what the tool solves, how it works, and the boundaries of its data.
Paste strict JSON to produce a PHP code fragment. Object properties become quoted keys joined to values with =>; JSON arrays become ordered lists; nested containers stay nested. Strings, numbers, booleans, and null are represented as PHP values. For example, {"name":"demo","ports":[80,443],"active":true} becomes a keyed PHP array with a nested port list and a boolean value. This is generated literal code, not a json_decode() call.
PHP arrays serve as both lists and maps, so the original JSON container type is not always recoverable: {} and [] both become an empty PHP array. Numeric-looking string keys may also be converted to integer keys when PHP evaluates the array.
Switch between short brackets ([]) and array(...) syntax. The choice applies at every nesting level. Indentation options are 2, 4, or 8 spaces; changing indentation affects layout rather than values. The output is only the literal: it does not add a PHP opening tag, variable name, return, or semicolon.
The converter parses using browser JSON parsing, whose numeric representation can round very large integer values. Identifiers such as account numbers that must retain every digit should be JSON strings, not numbers. Check nested shape and key types before copying into a project.
Guide
Follow the workflow and verify inputs and outputs with practical examples.
Use double quotes for JSON strings and names. Remove comments, single quotes, trailing commas, and JavaScript-only values such as undefined.
Enter the JSON in the input area or load the nested sample to inspect an object containing both lists and inner objects.
Choose bracket or long array syntax and 2, 4, or 8 spaces. A valid input regenerates using those formatting settings.
Add the assignment or return statement your file needs, then lint the result using the project’s PHP version.
Try {"ports":[80,443],"enabled":true,"note":null} and verify the list, boolean, and null value in the output. If you briefly make the input invalid while editing, verify the displayed output corresponds to the final valid input before copying.
Use cases
See how the tool fits into real work and everyday tasks.
Turn fixed JSON settings into a PHP map, then add the wrapper required by the configuration file.
Convert an API sample into nested test data and review important edge values before adding it to a test suite.
Compare a JSON object and list with PHP’s flexible array type, including empty containers and numeric-looking keys.
Q&A
Find concise answers to common questions and confusing cases.
The output is a value literal. Add the assignment, return statement, and punctuation that fit the surrounding PHP file.
No. Comments, unquoted names, single quotes, and trailing commas are outside strict JSON and must be corrected first.
Yes, but a scalar result is not an array. Use an object or array at the top level if the PHP code requires an array.
Very large numbers can lose precision, and apostrophes or backslashes in strings may need PHP escaping. Keep exact identifiers as JSON strings and inspect these characters before using the code.
Notes
Review scope, result limitations, and important precautions before use.
This is a syntax representation aid, not an application configuration validator or PHP runtime. Review escaping, numeric identifiers, numeric-looking keys, and empty containers; then lint and test in context. The converter’s quote and backslash handling is limited, so manually correct affected strings before use.
Related
Discover related tools, collections, and available API capabilities.