Skip to content
NSNormandin SystemsTHE EVERYDAY TOOLBOXMain site
{ }

Data / YOUR EVERYDAY TOOLBOX

PHP-Array to JSON

Convert PHP Array to JSON

✓ Free to use✓ No account neededHow to use this tool ↓
YOUR WORKSPACESee an example ↗

Opening your tool…

Runs in your browser. Check important results and keep a copy of your original files.

THE PRACTICAL GUIDE · NORMANDIN SYSTEMS

Get more from PHP-Array to JSON

PHP-Array to JSON converts PHP array syntax to JSON. The converter interprets supported PHP array expressions and represents their keys and values in JSON. A snippet containing function calls or runtime variables is not the same as literal array data. Convert a self-contained data expression. Check whether sequential integer keys become an array and whether sparse keys become an object. Use the worked example to understand what a successful result looks like, then compare it with a small sample of your own input. Keep the original available until you have checked the output in its destination. Conversion establishes a representation; it does not establish that the underlying information is correct or that the receiving application accepts every supported feature.

Guide updated October 13, 2026

How to use this tool

  1. Enter or load PHP array syntax using the input controls. Begin with the worked example or a small sample for which you know the expected result.
  2. Review any available conversion options, then inspect the JSON result. Resolve a reported parse error at its source before attempting to reuse the output.
  3. Check the example below against your own data. Check whether sequential integer keys become an array and whether sparse keys become an object.
  4. Copy or save the resulting JSON content using the controls provided, then validate it in the application or parser that will actually consume it.

SEE IT IN PRACTICE

A worked example

EXAMPLE INPUT
["name" => "Ada", "active" => true]
RESULT / WHAT TO EXPECT
{"name":"Ada","active":true}

String keys form a JSON object, and the boolean remains true rather than the string "true".

Objects and lists depend on the keys

A PHP array with consecutive integer keys can serialize as a JSON array, while a keyed associative array represents an object. Sparse integer keys may therefore produce a different JSON shape from a simple list. If the consumer expects a list, decide deliberately whether keys are meaningful before reindexing. Reindexing can make the shape convenient while discarding identifiers that the source intended to preserve.

Literal data and executable PHP

The converter is useful for self-contained array expressions whose values are visible in the snippet. An expression that calls a function, refers to a variable, or relies on an included file requires a PHP execution context instead. Isolate the data you intend to transfer. After conversion, inspect whether sequential numeric keys produced a JSON list or whether the value became an object with string property names.

When this tool is useful

  • Prepare JSON fixtures from PHP examples while retaining a separate copy of the source.
  • Use a small example to troubleshoot keyed arrays versus lists and identify a representation mismatch.
  • Create portable data from configuration snippets without manually rewriting every field or symbol.

Tips for a better result

  • A snippet containing function calls or runtime variables is not the same as literal array data. Convert a self-contained data expression.
  • Check whether sequential integer keys become an array and whether sparse keys become an object.
  • After changing formats, compare meaningful values rather than whitespace alone. Read the JSON output with its intended parser when exact types or escaping matter.

Frequently asked questions

Can the converter resolve PHP variables?

Use literal, self-contained array data. Runtime variables and function calls need a PHP execution context.

Why did my array become a JSON object?

The key structure may be associative or sparse rather than a consecutive list. Review whether those keys carry meaning.

Should I reindex a sparse array first?

Only if the keys are not meaningful and the consumer expects a list. Reindexing can discard identifier information.

What happens to the information I enter?

The utility processes your input in this browser. Some tools retain field values in browser storage or the URL; avoid entering secrets in shareable fields. Page and asset requests still go to the hosting provider. Read the privacy and offline-use notes for details.