Array Formatter
Make your nested Hashes and Arrays look neat and tidy! This tool beautifies and aligns items from JavaScript, Python, Ruby, and PHP dump functions like print_r, var_dump, and var_export, giving you more readable and properly indented code.
What is This Tool?
This free online beautifier helps you format and align arrays or hashes across popular languages like Ruby, PHP, JavaScript, and Python. It’s perfect for developers and data analysts who want clean, readable structures.
In addition to raw array/hash code, this tool also supports beautifying the output of:
- PHP functions like
print_r()
,var_dump()
, andvar_export()
- Python-style structures including
dict
,list
, and complex nested objects - JavaScript objects and arrays
- Output of frameworks/libraries like LangChain or custom formats like
Document(...)
orMyObject(...)
How to Use
- Paste or type your array/hash code or PHP dump output into the editor.
- Optionally adjust the indentation or enable value alignment.
- Click to format your structure.
You can download the result, copy it, or share a unique link. Sign in with Google or GitHub to save and access your beautified code later.
Understanding PHP Dump Outputs
PHP debugging functions like print_r()
, var_dump()
, and var_export()
output structured data, but the formatting can be hard to read when deeply nested.
print_r()
: readable format with nestedArray()
blocksvar_dump()
: verbose, includes type and length infovar_export()
: outputs valid PHP code structure
What is Document(...)
or MyObject(...)
?
In some Python libraries or frameworks, objects are printed using a constructor-like format such as Document(metadata={...}, page_content='...')
or MyObject(...)
. This tool can parse and format such object lists, including any deeply nested data.
Array vs Hash (Object/Dict): What’s the Difference?
- Array: ordered list of values (e.g.
[1, 2, 3]
) - Hash/Object/Dict: key-value pairs (e.g.
{"name": "Alice"}
)
These structures appear in many languages:
- Ruby:
[]
for arrays,{ key: value }
for hashes - PHP: uses
array()
for both arrays and hashes - JavaScript:
[]
for arrays,{ key: value }
for objects - Python:
[]
for lists (arrays),{ key: value }
for dicts (hashes)
Examples
JavaScript Array
const nums = [1, 2, 3, 4, 5];
JavaScript Object
{
"name": "Alice",
"age": 30
}
Python List
["apple", "banana", "cherry"]
Python Dict
{
"id": 1,
"name": "Bob"
}
LangChain Document
[
Document(
metadata={
"source": "/content/file.pdf",
"coordinates": {
"points": ((47.94, 47.29), (47.94, 74.42)),
"system": "PixelSpace"
}
},
page_content="Example text"
)
]
MyObject List
[
MyObject(
metadata={
"key1": "value1",
"key2": [1, 2, 3]
},
content="Some content here"
),
MyObject(
metadata={
"key1": "another",
"key2": [4, 5]
},
content="Another content"
)
]
Beautification Examples
Before: print_r()
Output
Array
(
[name] => Alice
[age] => 30
[address] => Array
(
[city] => Paris
[zip] => 75001
)
)
After Beautify
array(
"name" => "Alice",
"age" => 30,
"address" => array(
"city" => "Paris",
"zip" => 75001
)
)
Before: Python Dict
{'a':1,'b':{'x':10,'y':20},'c':[1,2,3]}
After Beautify
{
'a': 1,
'b': {
'x': 10,
'y': 20
},
'c': [
1,
2,
3
]
}
Before: JavaScript Array
const data = [1, {"a":2,"b":[3,4]}, 5];
After Beautify
const data = [
1,
{
"a": 2,
"b": [
3,
4
]
},
5
];
Before: Custom Object List
[MyObject(metadata={'key1': 'value1', 'key2': [1, 2, 3]}, content='Some content here'),
MyObject(metadata={'key1': 'another', 'key2': [4, 5]}, content='Another content')]
After Beautify
[
MyObject(
metadata={
'key1': 'value1',
'key2': [
1,
2,
3
]
},
content='Some content here'
),
MyObject(
metadata={
'key1': 'another',
'key2': [
4,
5
]
},
content='Another content'
)
]