Online Array Formatter

Beautify and align items in nested Hashes/Arrays from JavaScript, Python, Ruby and PHP dump functions (print_r, var_dump, var_export) for more readable and properly indented code.

Tags: beautify code format array

🚀 297,774 total conversions (79 this month)

Practice Python with coding challenges

Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.

All Python challenges
Easy

Distance Between Points

Compute the straight-line distance between two points.

You'll learn Pythagorean theoremSquare roots
BeginnerFunctionsLearning-pathmath
Easy

Count Pairs With a Sum

Count pairs of positions whose values add up to a target.

You'll learn Pairs of indexesAvoiding double counts
ArraysBeginnerLearning-pathNested-loops
Easy

Average of Three

Average three whole numbers.

You'll learn ArithmeticDivision
BeginnerLearning-pathVariables
Easy

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

You'll learn ArithmeticReturn values
BeginnerLearning-pathVariables
Easy

Join Customers and Orders

Join customers with their orders like a LINQ Join and report each customer's total spend.

You'll learn LINQ JoinGrouping
ArraysSorting
No solutions yet
Easy

To-Do List

Keep a list of tasks: add them, mark them done, remove them and report what is still pending.

You'll learn Typed collectionsRecords
BeginnerSimulationStrings
No solutions yet
Easy

Linked List Operations

Simulate a linked list: add at either end, remove from the front or by value, and reverse it.

You'll learn Linked listsSimulation
Data-structuresSimulation
No solutions yet
Easy

Sum a Flat JSON Object

Parse a flat JSON object whose values are integers and add up the values.

You'll learn JSON parsingString splitting
ParsingStrings
No solutions yet
Easy

WhenAll Total Time

Find how long a program takes when each group of tasks runs together with Task.WhenAll and groups run one after another.

You'll learn Async/awaitTask.WhenAll
ArraysBeginner
No solutions yet
Medium

Parallel Task Completion Order

Run tasks concurrently with at most k at a time and report the order in which they finish.

You'll learn ConcurrencyPriority queues
SimulationSorting
No solutions yet
Medium

Min Stack

Build a stack that reports its smallest element instantly after any push or pop.

You'll learn StacksRunning minimum
Data-structuresStacks
No solutions yet
Easy

Unique Records

Remove duplicate records that are equal by value, keeping the first of each in order.

You'll learn RecordsValue equality
BeginnerStrings
No solutions yet

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(), and var_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(...) or MyObject(...)

How to Use

  1. Paste or type your array/hash code or PHP dump output into the editor.
  2. Optionally adjust the indentation or enable value alignment.
  3. 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 nested Array() blocks
  • var_dump(): verbose, includes type and length info
  • var_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'
  )
]