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,698 total conversions (3 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

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
Medium

One Generation of a Genetic Algorithm

Breed the next generation of bit strings with tournament selection, single-point crossover and mutation.

You'll learn Genetic algorithmsEvolutionary search
OptimizationSimulationai
No solutions yet
Easy

Epsilon-Greedy Multi-Armed Bandit

Balance exploration and exploitation on a multi-armed bandit with epsilon-greedy action selection.

You'll learn Explore vs exploitBandits
Reinforcement learningaimachine learning
No solutions yet
Easy

Markov Chain State Distribution

Propagate a probability distribution through a Markov chain's transition matrix for a number of steps.

You'll learn Markov chainsProbability
Simulationaimath
No solutions yet
Medium

Value Iteration

Compute how valuable each state of a Markov decision process is by repeatedly applying the Bellman optimality update.

You'll learn Bellman equationMDPs
Reinforcement learningaimachine learning
No solutions yet
Medium

Q-Learning Updates

Apply the Q-learning update to a stream of experiences and watch rewards flow back to earlier states.

You'll learn Q-learningDiscounted rewards
Reinforcement learningaimachine learning
No solutions yet
Medium

Alpha-Beta Pruning

Evaluate a game tree with minimax and alpha-beta pruning, and count how many leaves the search really looks at.

You'll learn Alpha-beta pruningGame search
RecursionTreesai
No solutions yet
Medium

Minimax Tic-Tac-Toe

Pick the perfect tic-tac-toe move by searching the whole game tree with minimax.

You'll learn MinimaxGame trees
Recursionai
No solutions yet
Medium

A* Search on a Weighted Grid

Find the cheapest path across a grid of terrain costs with A*, the search algorithm behind game and robot pathfinding.

You'll learn A* searchHeuristics
GraphsGridsShortest-pathai
No solutions yet
Medium

Temperature and Top-K Sampling

Choose the next token like a language model does: keep the top k logits, apply temperature, and sample.

You'll learn Text generationSampling
aimachine learning
No solutions yet
Hard

Multi-Head Self-Attention

Project the input into queries, keys and values, run attention in several heads in parallel, and combine them.

You'll learn Multi-head attentionMatrix projections
aimachine learning
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'
  )
]