Paste JSON, get a Ruby Hash literal or Struct.new classes; symbol or string keys, null maps to nil, nested objects, zero upload.
- Runs locally
- Category Format Converter
- Best for Checking file type, size, metadata, and obvious mismatch signals before sharing.
How keys, nil and Structs are generated
Hash mode renders the JSON as a Ruby Hash literal: JSON null becomes nil, true/false stay as-is, numbers pass through verbatim, and strings are double-quoted with proper Ruby escapes. Keys can be symbols in shorthand form (name:), classic rocket form (:name => ), or plain string keys ("name" => ) — pick whatever your codebase uses. Struct mode emits Struct.new(:a, :b) class definitions plus the instantiation that fills them; every nested object becomes its own Struct named after the key path, and an array of objects folds all its elements into one shared Struct so a key missing from some elements simply passes nil. Everything runs in your browser; the JSON never reaches a server.
What this tool does
Paste any JSON payload and get back idiomatic Ruby in one of two shapes. Hash mode renders the JSON as a Ruby Hash literal: pick symbol keys in the modern shorthand form (name: value), the classic rocket form (:name => value), or plain string keys ("name" => value), and the tool maps every scalar the way Ruby expects. JSON null becomes nil, true and false stay as true and false, integers and floats pass through verbatim, and strings are double-quoted with correct Ruby escapes so a quote, a newline or an interpolation-looking sequence like the hash brace never breaks the literal. Struct mode generates Struct.new(:a, :b) class definitions plus the instantiation that fills them: every nested object lifts out into its own named Struct, and an array of objects folds all of its elements into one shared Struct so a key present in some elements and missing in others simply passes nil. Rename the root Struct, toggle keyword_init, share the exact input and options as a link, copy the result or download a .rb file. Everything runs in your browser; the JSON you paste never touches a server.
Tool details
- Input
- Text + Numbers + Structured content
- The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
- Output
- Live result + Copy + Download
- The result area focuses on usable output, with copy, download, or preview actions when supported.
- Privacy
- Browser-side processing
- The main tool logic does not call an external API, so inputs normally stay in the current tab.
- Save / share
- Shareable URL state
- Key settings are encoded in the URL so another person can reopen the same setup.
- Performance budget
- Initial JS <= 9 KB
- No WASM budget is declared, keeping the tool quick to open on mobile.
- Best fit
- Format Converter · Developer
- Category and role tags drive related tools, internal links, and quick fit checks.
How to use
-
1. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
3. Copy / Download
Copy the result or download to disk in one click.
How JSON to Ruby fits into your work
Use it before upload, handoff, archive, support review, or any moment where a file needs one local check before it leaves your machine.
File jobs
- Checking file type, size, metadata, and obvious mismatch signals before sharing.
- Preparing mixed folders for upload, archive, intake, or review.
- Keeping sensitive files in the browser instead of sending them to an account-based service.
File checks
- Do not treat the extension alone as proof of the real file type.
- Review metadata before a file goes to customers, vendors, or a public page.
- Keep the original file until the copied, converted, or exported result is verified.
Good next steps
These links move the current task into a more complete workflow.
- 1 JSON to TypeScript Interface JSON to TypeScript interface — paste JSON, get clean interfaces with union types from arrays, optional vs required detection, root name customizable. Open
- 2 TypeScript to Zod Schema TypeScript to Zod schema converter — paste interface/type, get z.object() schema, supports unions/optionals/nested/generics/enum/Record/Map/Set. Open
- 3 JSON to Python Dataclass JSON to Python — paste JSON, get @dataclass or Pydantic v2 models with type hints, Optional inference, nested classes, snake_case fields and aliases. Open
Real-world use cases
Seed a Rails fixture or test factory from a real payload
You captured an API response in a log and need it as a Ruby Hash in a spec. Paste the JSON, keep symbol keys in shorthand form, copy the output straight into a let block or a FactoryBot trait. null fields come out as nil, nested objects as nested hashes, so the fixture matches the wire shape exactly without you retyping a single brace.
Convert a config.json into a typed Ruby config object
Your service reads a JSON config but you want attribute readers and a fixed shape rather than h["server"]["port"] string-key chains. Switch to Struct mode, name the root Config, and you get Config, ConfigServer and ConfigServerTls Structs plus the instantiation. Now config.server.port is a real method call, type-checked by shape, not a Hash lookup that returns nil on a typo.
Port a JSON snippet into an irb or pry session
You are debugging and want a sample object in the console as a live Ruby value. Paste the JSON, pick the rocket key style if the source uses dashed keys, copy, and paste into pry. The literal evaluates on the spot, so you can poke at it with .dig, .map and .select instead of squinting at raw JSON text.
Build seed data for db:seed from an export
A teammate hands you a JSON export of reference rows. Paste the array of objects, stay in Hash mode with symbol keys, and you get a Ruby array of hashes ready for Model.create!(attrs) in seeds.rb. Keys that one record has and another lacks render explicitly as nil, so every create call gets the same attribute set.
Common pitfalls
Expecting symbol shorthand to work on every key. The shorthand label form is only valid for keys that are legal Ruby labels. For a key like first-name the tool falls back to the quoted symbol form or the rocket arrow form so the output still parses; do not hand-edit it back to a bare label.
Forgetting that Struct positional order follows the JSON key order. With keyword_init off, the new call maps arguments by position, so reordering the JSON keys silently reassigns values. Keep keyword_init on when the source key order is not stable, so each value is bound to its named member.
Treating JSON null and a missing key as different things in Struct mode. Both render as nil, because a folded Struct must fill every member for every element. If the distinction matters to your code, keep the data as a Hash and check key presence with has_key? rather than relying on the Struct.
Privacy
Conversion is plain JavaScript that runs in your browser tab: the built-in JSON parser reads your input, the mapping turns it into Ruby source, and nothing is sent anywhere. There is no logging of the JSON you paste. The one caveat is the Share link, which encodes your input and options in the URL query string, so a link pasted into chat will record those in the recipient server's access log. For a sensitive payload, use the Copy button and paste the Ruby text instead of sharing the URL.
FAQ
Tool combos
Folks in your role tend to reach for these alongside this tool.
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only
- Age Difference Calculator The exact gap between two birthdays — years/months/days, percentage, and the date one person is twice the other's age — browser-only