Ruby Hash to JSON Converter

Paste a Ruby hash, get clean JSON. Handles hashrockets, symbol keys, modern shorthand, nesting, and nil, with keys sorted alphabetically so the output is stable and diff-friendly. Everything runs in your browser: nothing you paste is uploaded, logged, or stored.

 

What this converter handles

Ruby hash syntax is not JSON, and the differences are exactly the parts that break a naive find-and-replace: hashrockets, symbols, single quotes, and Ruby literals. This converter uses the same real parser as the RubyHash diff tool, a hand-written recursive descent parser that reads the input into an actual data structure. It converts:

Why the keys come out sorted

Hashes that come from database rows, serializers, or params often list their keys in a different order on every run. That ordering noise is harmless in Ruby but it makes JSON output useless for comparing, committing to fixtures, or eyeballing. Sorting keys alphabetically makes the output deterministic: the same data always produces the same JSON. Untick the box if you want the original order preserved.

Where the data goes

Nowhere. Parsing and conversion happen in JavaScript in this page. You can disconnect from the internet after the page loads and it still works, which matters when the hash you are converting came out of a production console.

Comparing two hashes instead?

If you are converting a hash because a test failed and you want to see what changed, skip the manual step: the RubyHash diff tool takes the raw failing output, parses both sides, and highlights exactly which keys changed, including type changes like nil to String. The guide to debugging Ruby hash diffs covers the whole workflow.