PureDevTools

JSON to Ruby Hash/Class Converter

Paste JSON, get Ruby hashes or class definitions — attr_accessor, initialize, from_json — copy or download as .rb

All processing happens in your browser. No data is sent to any server.

Options

Output: 385 charsMode: HashKeys: Symbols

You’re building a Rails API client and the endpoint returns deeply nested JSON. You could parse it with JSON.parse and navigate hashes everywhere — data["user"]["profile"]["email"] — but one typo means a silent nil instead of a helpful error. A proper Ruby class with attr_accessor gives you method-style access, IDE autocomplete, and clearer code.

What This Tool Does

Paste any JSON and get Ruby code instantly — either plain hashes with symbol keys, or full class definitions with attr_accessor, initialize, and from_json class methods. Nested objects become nested classes. Arrays of objects are typed correctly.

Everything runs in your browser. Your data never leaves your device.

When to Use This

Ruby Hash vs Class Output

Hash output gives you a ready-to-use Ruby hash literal with symbol keys — useful for quick scripting or test fixtures.

Class output generates full Ruby classes with:

FAQ

Does this send my JSON to a server?

No. All processing happens entirely in your browser using JavaScript.

How are nested objects handled?

Each nested JSON object becomes its own Ruby class, named after the parent class and the property key in PascalCase.

What about null values?

JSON null maps to Ruby nil. Fields are initialized with nil as the default when the value is null.

Related Tools

More JSON Tools