Paste a PHP array literal and read it as a table. Once
the array is wide, columns are quicker to scan than
print_r output in a browser tab. The literal is
parsed in this page, so you do not need a local PHP install.
Once it renders, Copy for Email pastes the table
into Gmail, Outlook or Google Docs with its borders intact,
Copy HTML gives bare <table>
markup, and Copy Markdown gives a pipe table for
a README or a pull request.
[
['id' => 1, 'name' => 'John Doe', 'role' => 'Admin', 'active' => true],
['id' => 2, 'name' => 'Jane Smith', 'role' => 'User', 'active' => false],
['id' => 3, 'name' => 'Bob Johnson', 'role' => 'Editor', 'active' => true]
] A wide associative array is slow to read as indented text. In a table, you compare one field across every row by reading down a column.
Nothing is executed. The literal is read as data, so you can paste one from a file and inspect it on a machine with no PHP.
<?php
$users = [
["id" => 1, "name" => "John Doe", "role" => "Admin", "active" => true],
["id" => 2, "name" => "Jane Smith", "role" => "User", "active" => false],
];
// Header from the keys of the first row
$columns = array_keys($users[0]);
echo "<table>\n<thead><tr>";
foreach ($columns as $c) echo "<th>" . htmlspecialchars($c) . "</th>";
echo "</tr></thead>\n<tbody>\n";
foreach ($users as $row) {
echo "<tr>";
foreach ($columns as $c) {
$v = $row[$c] ?? "";
if (is_bool($v)) $v = $v ? "true" : "false";
if (is_array($v)) $v = json_encode($v);
echo "<td>" . htmlspecialchars((string) $v) . "</td>";
}
echo "</tr>\n";
}
echo "</tbody>\n</table>\n"; Cast booleans yourself: (string) false is an empty string, so it would render as a blank cell.
<?php
$users = [
["id" => 1, "name" => "John Doe", "role" => "Admin"],
["id" => 2, "name" => "Jane Smith", "role" => "User"],
];
// var_export() prints valid PHP you can paste into the tool later
var_export($users);
echo PHP_EOL;
// json_encode() hands the same data to JavaScript or Python
echo json_encode($users, JSON_PRETTY_PRINT), PHP_EOL;
// print_r() is for humans only: it is not parseable // The array exported from PHP with json_encode($users)
const users = [
{ id: 1, name: "John Doe", role: "Admin" },
{ id: 2, name: "Jane Smith", role: "User" },
];
const columns = Object.keys(users[0]);
const esc = (v) => String(v ?? "").replace(/&/g, "&").replace(/</g, "<");
const table = document.createElement("table");
table.innerHTML =
`<thead><tr>${columns.map((c) => `<th>${esc(c)}</th>`).join("")}</tr></thead>` +
`<tbody>${users.map((u) => `<tr>${columns.map((c) => `<td>${esc(u[c])}</td>`).join("")}</tr>`).join("")}</tbody>`;
document.body.appendChild(table); Embed the JSON in a page with <?= json_encode($users) ?> inside a script tag, or fetch it from an endpoint.
The parser reads what var_export() emits: string and numeric keys, integers, floats, booleans, null and nested arrays in either syntax. It does not run PHP, so expressions, heredocs, objects and class constants are not supported. When in doubt, run var_export() on the array on the server and paste the output.
The shape that renders well here, a sequential list of associative arrays with matching keys, is also the shape json_encode() turns into a clean JSON array of objects. Keep your PHP data in that form and it moves between the JSON, CSV and table tools without any restructuring.
This tool follows the specifications below. Read them when you need the exact normative wording, for example to settle an edge case between two implementations.
Both array( ... ) and [ ... ], with string or integer keys and nested arrays.
Yes. var_export() produces valid PHP syntax. print_r() output is not PHP syntax, so it cannot be parsed; use var_export() instead.
An array of associative arrays with matching keys, which maps directly to rows and columns.
Nested arrays are shown as JSON text inside the cell, so the table keeps one column per key.
For a file, use the PHP Array to CSV or PHP Array to JSON tools with the same input. For the clipboard, use the three copy buttons above the table: Copy for Email, Copy HTML and Copy Markdown.
Paste the array, click Copy for Email, then paste into the message in Gmail, Outlook or Apple Mail. The clipboard holds a rich-text table with inline borders and a shaded header, which survives in email clients that strip stylesheets. It also pastes as a native table into Google Docs, Word and Notion, which is handy for sharing a config array or a query result with someone who does not read PHP.
Copy HTML gives plain <table> markup without styles or classes, for a documentation page, a CMS or an HTML email template that has its own CSS. Copy Markdown gives a GitHub pipe table, for a README, a code review comment or a wiki page, where a rendered table is clearer than a pasted array literal. Both read the table as shown, with nested arrays as JSON text.
Export it with PHP array to JSON or PHP array to CSV. JSON data has its own viewer at JSON to Table.