What is JSON to Julia Struct Generator?
This tool converts JSON data into Julia struct definitions with type annotations. It generates ready-to-use Julia code with automatic type inference, nested struct support, Union types for nullable fields, and optional JSON3.jl and StructTypes.jl integration.
How to Use
- Paste your JSON object or array into the input area
- Configure options: root struct name, mutable struct, module wrapper, JSON3.jl, StructTypes.jl, Union{T, Nothing} for null
- Click "Generate Julia Structs" to create the code
- Copy the output and add it to your Julia project
Why Use This Tool?
Tips & Best Practices
- Use realistic sample data for accurate type inference
- Enable mutable struct if you need to modify fields after creation
- JSON3.jl is the recommended JSON library for Julia — enable it for parsing support
- StructTypes.jl works with JSON3.jl for fine-grained control over serialization
Frequently Asked Questions
What is JSON3.jl?
JSON3.jl is a fast, flexible JSON parsing and serialization library for Julia. It provides the JSON3.read function to parse JSON strings directly into Julia structs, and JSON3.write to serialize structs back to JSON.
What is StructTypes.jl?
StructTypes.jl is a companion package to JSON3.jl that provides the @StructType macro and other annotations for controlling how Julia structs are serialized and deserialized. It allows you to specify custom naming strategies, omit fields, and handle non-standard JSON structures.
How are JSON types mapped to Julia?
JSON strings → String, integers → Int64, floats → Float64, booleans → Bool, null → Union{T, Nothing} (when enabled) or Any, arrays → Vector{T}, and nested objects → separate Julia structs.
What is the difference between struct and mutable struct?
In Julia, a struct is immutable — its fields cannot be changed after creation. A mutable struct allows field values to be modified. Use mutable struct when you need to update fields, and regular struct for immutable data which is generally preferred for performance and safety.
Is my data sent to a server?
No, all processing happens entirely in your browser. Your JSON data never leaves your device.