BudiBadu Logo
Toolbadu

json_decode online

Simulate PHP's json_decode() function online. Test JSON decoding with all parameters: associative arrays, depth limits, and flags. See exactly how PHP decodes your JSON without needing a server.

json_decode(string $json, ?bool $associative = null, int $depth = 512, int $flags = 0): mixed

Parameters

JSON String Input

0 chars
Loading editor...

PHP Output

// PHP output will appear here

Sample JSON for Testing

Click on any example to test the decoder:

json_decode() Function Guide

About json_decode()

The json_decode() function is PHP's built-in method for converting JSON strings into PHP variables. It parses a JSON encoded string and converts it into a PHP value (object, array, or scalar). This tool simulates the exact behavior of PHP's json_decode() so you can test and understand how your JSON will be decoded in a real PHP environment.

  • Converts JSON strings to PHP objects or arrays
  • Supports depth limiting to prevent stack overflow
  • Handles various flags for special decoding behavior
  • Returns NULL on invalid JSON with proper error handling
  • Preserves data types (strings, numbers, booleans, null)

Parameters Explained

$json: The JSON string being decoded. Must be valid JSON syntax.

$associative: When set to true, returned objects will be converted into associative arrays. When null or false, objects are returned as stdClass instances.

$depth: Maximum nesting depth of the structure being decoded. PHP will throw an error if the depth limit is exceeded, preventing infinite recursion. Default is 512.

$flags: Bitmask of JSON decode options. Common flags include JSON_BIGINT_AS_STRING (decode large integers as strings) and JSON_OBJECT_AS_ARRAY (decode objects as arrays).

Request a Feature

Have an idea to improve this tool? Share your suggestions and help us make it better! (One request per day)

0/1000 characters