Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<?php $data = [ "user" => "Alice", "age" => 30, "tags" => ["admin", "editor"], "meta" => ["joined" => "2024-01-01"], ]; // Compact output $json = json_encode($data); // Pretty-printed with Unicode characters preserved $pretty = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); // Check for errors if (json_last_error() !== JSON_ERROR_NONE) { throw new RuntimeException("JSON encoding failed: " . json_last_error_msg()); }
Result
Open