JSON to C Struct Generator

Paste JSON, get C code instantly. Private, in your browser.

Input

Output

Ready
Ln 1, Col 1

Convert JSON to C in one step

Paste JSON and get C typedef structs that mirror its shape, ready to fill with a JSON library such as cJSON or jansson.

How to use it

  1. Paste a JSON sample into the Input panel, open a file, or drop it onto the page. A sample is already loaded so you can see the result.
  2. The C code appears instantly in the Output panel and updates as you type.
  3. Rename the top-level type under Settings → Root type name, and use Sort keys to order fields alphabetically.
  4. Copy the code or Download it as Root.h.

What the C generator produces

  • Strings as char *, numbers as int64_t or double, booleans as bool.
  • Optional numbers and booleans get a has_ flag; optional objects are pointers.
  • Arrays are a pointer plus a _count field.
  • Structs are declared in dependency order with snake_case members.

Using the generated C code

Fill the structs with cJSON, for example:

cJSON *json = cJSON_Parse(text);
Root root = {0};
const cJSON *name = cJSON_GetObjectItemCaseSensitive(json, "name");
if (cJSON_IsString(name)) root.name = strdup(name->valuestring);
cJSON_Delete(json);

More JSON tools

All tools are free and run privately in your browser.

JSON to C FAQ

Does it generate parsing code for C?

No. C has no standard JSON library, so it generates the data structures. Fill them with cJSON, jansson, json-c or a similar library.

Is my data uploaded to a server?

No. The JSON to C runs entirely in your browser using JavaScript. Your data is never uploaded, logged or stored, and the tool keeps working offline after your first visit.