DevConvert
Free Online Tool

Ruby Hash to JSON Converter

Convert Ruby hashes, symbols, and object representations to JSON instantly. Handles hash rockets (=>), symbols (:key), nil, and Rails ActiveRecord output. Free online Ruby hash to JSON converter.

Try sample:
Input
Output

Output will appear here

Press ⌘ Enter to convert

How It Works

  1. 1Copy a Ruby hash from your Rails console, logs, or debugger
  2. 2Paste it into the converter
  3. 3Get valid JSON with keys as strings and Ruby-specific values normalised

Examples

Basic hash

Input

{:id=>1, :name=>"Alice", :active=>true, :score=>nil}

Output

{
  "id": 1,
  "name": "Alice",
  "active": true,
  "score": null
}
Symbol values

Input

{:status=>:active, :role=>:admin, :tier=>:premium}

Output

{
  "status": "active",
  "role": "admin",
  "tier": "premium"
}
Nested hash

Input

{:user=>{:id=>1, :address=>{:city=>"Bangalore", :zip=>"560001"}}, :verified=>true}

Output

{
  "user": {
    "id": 1,
    "address": { "city": "Bangalore", "zip": "560001" }
  },
  "verified": true
}

Frequently Asked Questions

What Ruby syntax differences does this handle?

DevConvert handles: hash rocket syntax (:key=>value), symbol keys (:key), symbol values (:value), nil → null, and Ruby's inspect output format.

Can I paste output from .inspect or puts hash.inspect?

Yes. Ruby's .inspect output is exactly the format DevConvert is designed to parse. Copy the output from your Rails console or logs and paste it directly.

Does it handle new-style Ruby hash syntax (key: value)?

Yes. Both hash rocket ({:key => value}) and new Ruby hash syntax ({key: value}) are supported.

What about ActiveRecord objects?

Use the ActiveRecord converter for #<User id: 1, name: "Alice"> style output. The Ruby Hash converter handles {…} syntax only.

Related Tools