Var Dump Formatter

Beautify and format PHP var_dump() output.

Var Dump Formatter

Format, beautify, and analyze PHP var_dump and print_r outputs

Characters: 0
Format Options
Supports var_dump, print_r and JSON, including dumps copied from a browser page where everything landed on one line. It adjusts whitespace and indentation without altering data.

Paste a dump above and click "Format" to see the output here

What is a PHP Var Dump Formatter?

A PHP var_dump() formatter is a specialized utility designed to take the raw, often messy output of PHP's debugging functions and transform it into a structured, readable format. When developers use var_dump() or print_r() on large arrays or deeply nested objects, the resulting output can be a single, unformatted block of text that is nearly impossible to analyze.

CodeHelper's Var Dump Beautifier instantly cleans up this output, adding proper indentation, line breaks, and structure, making it easy to see key-value pairs and object properties.

Var_dump vs. Print_r: Which one should you use?

  • var_dump($var): Provides the most detailed information, including data types (string, int, float) and lengths. It is essential for strict type checking.
  • print_r($var): Produces a more "human-readable" output but omits data types. It's great for a quick look at array structures.
  • var_export($var): Generates valid PHP code that can be copy-pasted back into a script to recreate the variable.

How to use the Var Dump Pretty Printer

  1. Paste your raw PHP output into the input field.
  2. Click the "Format" button.
  3. The tool will automatically detect if it's a var_dump, print_r, or even JSON.
  4. Copy the beautified result for your documentation or debugging logs.

Whether you are debugging a WordPress plugin, a Laravel application, or a legacy PHP script, having a clear view of your data is the first step toward fixing bugs faster.

Frequently Asked Questions

Why is my var_dump output all on one line?

When PHP prints to a web page, the browser collapses the newlines and indentation of var_dump and print_r, so a copied dump arrives as a single line. The formatter detects this and rebuilds the structure: one key per line, arrays and objects indented, braces and parentheses on their own lines. Wrapping the call in <pre> tags or viewing the page source avoids the problem at the origin.

How does the tool tell var_dump, print_r and JSON apart?

It looks at the syntax. var_dump writes lowercase types with sizes such as array(2) {, string(3) "foo" and int(1). print_r writes Array and Object with the contents in parentheses and no types. Anything that starts with { or [ and parses as JSON is treated as JSON. The detected format is shown under the input box.

Does formatting change the values?

No. Only whitespace and indentation are touched. Keys, string lengths, types and values stay exactly as PHP printed them, so the formatted dump is still a faithful record for a bug report or a log.

How can I make var_dump readable directly in PHP?

Install Xdebug, which replaces var_dump with a colored, indented version, or wrap the output in echo <pre> tags before dumping so the browser keeps the line breaks. In the terminal, var_dump is already formatted. This tool is for dumps you already have in a log, a ticket or a browser page.

Free forever, no ads, no tracking. Support the project