Loading...

JSONfn - Easy code from JSON

Visualize JSON

Pick properties

Generate clean, configurable code

Fast and clutter-free classes/interfaces/types/zodschemas.
Supported languages: C#, TypeScript
Full guide: Docs

31/01

Fixed bug which prevented JSON with kebab-case keys from parsing

15/02

C# support for backing fields, customizing get/set, customizing public/private

15/02

C# handles plural naming for collections grammatically

15/02

Added copy-to-clipboard button

1. Paste JSON
2. Pick properties
3. Configure code

Documentation

Load JSON and get a visual overview of the data structure.
Pick the properties needed for your application.
Effortlessly configure the generated code.

1. Load JSON

Load JSON from text

Press Load TEXT and paste JSON text into the textarea field.
Press OK.

Load JSON from URL

Press Load URL and paste a URL into the input field.
If needed, provide any additional headers required for authorization etc.

Example bearer:
Header key: Authorization, Header value: Bearer -your-token-

Example basic username/password:
Header key: Authorization, Header value: Basic -username:password-

Example basic base64:
Header key: Authorization, Header value: Basic -base64-key-, check Base64

2. Pick properties

The loaded JSON is rendered as a tree structure, with objects and arrays rendered as nested branches.

Selecting key-value-pairs will generate properties for the type it belongs to and all necessary ancestor relationships if the type is a descendant of root.

Complex types are noted as '{}' and '[]' for objects and arrays respectively.
Primitive types and arrays are noted as-is.
When the JSON value is null or an empty array, the type is noted as 'object' or 'object[]' (C#), 'null' or 'unknown[]' (TypeScript).

3. Configure generated code

Setting an option in the menu will toggle that option for all properties

Setting an option in the tree will toggle that option for the current property

Collections can be set to allow null or undefined items

C# options

Backing field
Getter / Setter
Public / Private
JSON library annotations
JSON library
  • System.Text.Json
  • Newtonsoft.Json
Naming convention

    Selecting a naming convention will generate a JsonProperty / JsonPropertyName annotation for all properties.

TypeScript options

Optional
ZodSchema

Setting this option will generate a ZodSchema for your class/type/interface

Additional information

C#

Type inconsistency / Unions

Because C# does not currently support unions, JSON key-value-pairs with type inconsistencies will generate multiple properties that map from the same key.

                "continent": [
                {
                "name": "Africa",
                "population": 1400000000,
                },
                {
                "name": "Antarctica",
                "population": "0",
                },
              
                public class continent
                {
                public string name { get; set; }

                // Use json annotations to map this property
                public int population_int { get; set; }

                // Use json annotations to map this property
                public string population_string { get; set; }
              

Known bugs

  • JSON with keys including a '^' character will parse incorrectly.

Help maintain this project by reporting bugs to hello@jsonfn.com .

Go