Prettify JSON

Format JSON with proper indentation for improved readability and debugging.

Code

Utilities
require 'json'
return JSON.pretty_generate(JSON.parse(jsonStr))

Parameters

JSON string to format.

Number of spaces for indentation.

Server

More Ruby Snippets