Paste C on the left and click "Convert" — we will turn it into JSONPaste C code

What this tool does

If you have ever needed a JSON payload that mirrors a C struct — for a gcc-built service test, an embedded device config, or a bit of docs — you know how it normally goes: pull in cJSON, write the per-field glue, rebuild, debug. Paste the C here and get valid JSON back without touching a Makefile. It handles a single designated initializer, a header with several structs, or something with nested types and arrays — same result: a clean JSON document with every field preserved.

The converter understands how C values actually serialize. int, long, size_t, float, and double all become JSON numbers. char arrays and string literals become JSON strings. bool from stdbool.h becomes true/false. Fixed arrays (int items[3]) become JSON arrays with the right length. Nested structs — an Address inside an Order, say — expand into nested JSON objects. The behaviour tracks the C language reference.

C99 designated initializers (.field = value) are fully supported, which is the usual way you see real-world struct literals written today. typedef aliases are resolved, and enum values come out as either their numeric value or the symbol name depending on context. Union types serialize the active member. Pointer members to NULL become JSON null; otherwise the pointed-to value is expanded. Paste multiple structs at once and each one becomes a top-level key in the output.

How to use it

Three steps. Works the same for a two-line initializer as it does for a full header with twenty typedefs.

1

Paste your C (or load the sample)

Drop your C into the left editor as-is. A struct definition, a typedef, a designated initializer, multiple structs, or nested arrays — all fine. Click Load Sample to see a realistic example first.

You do not need to remove #include directives or compiler-specific attributes. Leave the ISO C syntax intact — the parser handles it. Both C89 and modern (C11/C17/C23) are fine.

2

Hit Convert

Click the green Convert button. The tool reads the C, walks every struct, expands initializers, and emits the JSON in one pass. A loading indicator shows while it runs.

3

Copy the JSON

The right panel fills with indented JSON. Copy it into your HTTP client, embedded firmware config, test fixture, or README. That is the whole loop — no build step.

When this actually comes in handy

Embedded config & firmware

You have a device config struct in C and need a JSON version for a REST endpoint or provisioning tool. Paste the struct, grab the JSON, ship it.

API request payloads

A C service wrapping a third-party API. Paste the request struct, get JSON you can test with curl before wiring up cJSON in production.

Unit test fixtures

Turn the designated initializers from your unit tests into JSON seed files for integration tests or golden-file comparisons.

Docs that match the code

Generate JSON examples for a README or protocol doc straight from your real structs, so the docs stay in sync with the header file.

Common questions

Do I need cJSON or Jansson installed?

No. This tool runs server-side and does not compile your code — you get JSON without pulling in a serialization library. If you want a runtime option, cJSON is the usual pick; Jansson is another good one.

Does it understand designated initializers and typedefs?

Yes. C99 designated initializers (.field = value) are fully supported, and typedef aliases are resolved back to their underlying struct. Nested designated initializers expand the same way a compiler would lay them out.

What about arrays, pointers, and NULL?

Fixed-size arrays become JSON arrays with the right element count. Pointer members that are NULL become JSON null; otherwise the pointed-to value is expanded. Arrays of structs work the same way — each element is a nested JSON object.

How are enums and unions handled?

enum values come out either as the symbol name or the numeric value depending on context. union types serialize the currently active member. Bitfields (unsigned flags : 4) become numbers.

Is my code stored?

Your code is sent to the backend for conversion and is not persisted — we do not log the payload. If the code is genuinely sensitive (embedded firmware with secrets, internal protocol details), give it a review before pasting.

What if the C has macros or compiler extensions?

Macros that expand to a value work; function-like macros that do real logic are treated as opaque and emitted as null rather than halting. GCC and MSVC attributes (__attribute__, __declspec) are tolerated and ignored.

Other tools you may need

C to JSON is one piece of the puzzle. These pair well with it: