I Help You

PHP print_r() Parser

Convert PHP print_r() output into JSON, JavaScript, Python, or PHP array. Free, and it runs entirely in your browser — nothing you enter is uploaded.

How to use the PHP print_r() Parser

1. Paste the output of PHP's print_r() or var_dump() style output into the left panel.

2. Select your target format: JSON, JavaScript, Python, or PHP Array.

3. The converted structure appears instantly on the right — click Copy to use it.

What is it?

PHP's print_r() function outputs a human-readable representation of arrays and objects. It's commonly used for debugging, logging, or exporting configuration from PHP applications. However, this format is specific to PHP and cannot be directly consumed by JavaScript, Python, or other languages without parsing.

This tool parses the print_r() format — including nested arrays and objects of any depth — and converts the result to your chosen target format. JSON is universally supported. The JavaScript and Python outputs use native literal notation. The PHP Array output regenerates a clean, modern [] array syntax suitable for use in PHP code.

Example

PHP print_r() Output
Array
(
    [name] => John
    [age] => 30
    [skills] => Array
        (
            [0] => PHP
            [1] => JavaScript
        )
)
↓
JSON (converted)
{
  "name": "John",
  "age": 30,
  "skills": [
    "PHP",
    "JavaScript"
  ]
}

Switch to JavaScript, Python, or PHP Array output using the format tabs above the result.

Benefits

Convert PHP debug output to usable JSON without writing code

print_r() output is human-readable but not machine-parseable — convert to JSON to work with the data programmatically.

Extract data from legacy PHP application logs

Parse print_r() dumps from log files to analyse data structures without needing a running PHP environment.

Migrate PHP-serialised data to modern formats

Convert legacy print_r() data dumps to JSON, Python dicts, or JavaScript objects as part of a PHP-to-modern stack migration.

Debug PHP APIs that return print_r() output instead of JSON

Parse the output to understand the data structure being returned by legacy PHP backends before building client integrations.

Frequently asked questions

Does this support nested arrays?

Yes — nested arrays and objects at any depth are fully supported. The parser recursively processes the indented Array blocks, matching each [key] => Array block and its children.

What is the difference between print_r() and var_dump()?

print_r() outputs a simplified human-readable structure without type information. var_dump() includes type annotations (string(4), int(30), etc.). This tool parses the print_r() format specifically. For var_dump() output, you would need a different parser.

Are numeric keys converted to array indices?

Yes — if all keys in an array are consecutive integers starting at 0 (0, 1, 2, ...), the output is a proper array ([] in JSON/Python/JS, sequential [] in PHP) rather than an object/dict with string keys.

Are PHP objects (stdClass) supported?

Yes — PHP objects printed with print_r() appear as 'ClassName Object (...)'. The parser detects the Object suffix and treats the block the same as an Array, extracting all properties as key-value pairs.