JSON to Clojure Map Generator

Convert JSON to Clojure defrecord definitions or map literals with keyword keys.

What is JSON to Clojure Map Generator?

This tool converts JSON data into Clojure defrecord definitions or map literals with keyword keys. It automatically transforms JSON keys to Clojure keywords and handles nested structures, vectors, and all primitive types.

How to Use

  1. Choose the output format: defrecord for type definitions or map literal for direct data
  2. Paste your JSON data into the input area
  3. Click "Generate" and copy the output into your Clojure project

Why Use This Tool?

Automatically convert JSON keys to Clojure keywords (:key)
Generate defrecord definitions for structured data types
Generate map literals for immediate use in Clojure code
Handle nested objects and arrays as Clojure maps and vectors
Preserve data types: numbers, strings, booleans, nil

Tips & Best Practices

  • Use defrecord when you need named types with field validation
  • Use map literals when you need immediate data structures
  • Nested objects become nested maps or separate defrecords
  • JSON arrays are converted to Clojure vectors [item1 item2]

Frequently Asked Questions

How are JSON types mapped to Clojure?

JSON strings → "string", numbers → 123 or 3.14, booleans → true/false, null → nil, arrays → [item1 item2] (vectors), objects → {:key value} (maps).

What is defrecord in Clojure?

defrecord defines a record type in Clojure, which is a named data structure with a fixed set of fields. Records provide better performance than maps for known field sets and implement Java interfaces.

Why use keyword keys?

Keywords in Clojure (starting with :) are the idiomatic way to represent keys in maps. They are efficient for lookups and can be used as functions to extract values from maps.

How are nested objects handled?

In defrecord mode, nested objects become separate defrecord definitions. In map literal mode, nested objects become nested Clojure maps with proper indentation.

Is my data sent to a server?

No, all processing happens entirely in your browser. Your JSON data never leaves your device.

Related Tools