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

What this tool does

If you have an F# record or a discriminated union and you need a JSON payload for a test, an HTTP call, or a .NET integration, writing the body by hand is a pain. Paste the F# here and you get back valid JSON. One record, a union of a few cases, or a whole module — same flow.

The converter follows the behaviour of the JSON libraries most F# code uses. System.Text.Json with the F# converter, Newtonsoft.Json, and Thoth.Json all turn record fields into JSON keys — that is exactly what happens here. int, float, decimal, and bigint become JSON numbers. bool stays a boolean. DateTime and DateTimeOffset come out as ISO-8601 strings. string option emits the value when Some x or null when None.

Discriminated unions serialize with a discriminator so the JSON round-trips cleanly. A type Status = | Paid | Refunded of Guid comes out as {"Case":"Refunded","Fields":["..."]} or a custom tagged shape when JsonUnionCase attributes are present — matching what the dotnet/fsharp team's serializers produce. Lists, arrays, and sequences become JSON arrays. Map<string, 'T> becomes a JSON object. Tuples become JSON arrays. If you prefer a deeper dive into idiomatic F# modelling, fsharpforfunandprofit.com is worth bookmarking.

How to use it

Three steps. Works the same whether you paste one record or a whole Domain.fs.

1

Paste your F# (or try the sample)

Drop your F# into the left editor as-is. A record, a discriminated union, a record instance using { ... } syntax, or multiple types — all fine. Click Load Sample for a realistic example.

Keep module, namespace, open, and attribute declarations — the parser ignores what it does not need. The official F# language reference is a good backup.

2

Hit Convert

Click the green Convert button. The tool reads the F#, walks every record field and union case, and produces JSON in one pass. A short loading indicator shows while it runs.

3

Copy the JSON

The right panel fills with indented JSON. Paste it into a Giraffe or Saturn request, an xUnit fixture, a Fable test, or your API documentation.

When this actually comes in handy

Giraffe / Saturn test fixtures

You need a JSON body to POST to a Giraffe endpoint in a test. Paste the command record, get the payload, drop it into the spec.

Fable front-end mocks

Turn your F# domain records into mock JSON responses for a Fable or Elmish front end — no more hand-rolled JS objects that drift from the types.

Azure Functions payloads

Generate the JSON body you need to call an Azure Function written in F# — works well when you are iterating on input shape.

Docs that match your types

Produce JSON samples for API documentation or a README straight from your actual records, so the docs never fall behind.

Common questions

How are Option types serialized?

Some x becomes the value x; None becomes JSON null. That matches the default behaviour of Thoth.Json and the F# converter in System.Text.Json.

What do discriminated unions look like in JSON?

By default: {"Case":"CaseName","Fields":[...]} — the tagged format that round-trips back to F#. If the code uses custom attributes (JsonUnionCase or similar), the converter respects them and emits the tailored shape instead.

How does it handle DateTime, DateTimeOffset, Guid?

DateTime and DateTimeOffset come out as ISO-8601 strings. Guid is a standard 8-4-4-4-12 hex string. This matches what you would get from System.Text.Json out of the box.

Lists, arrays, maps — how do they map?

list, array, and seq all become JSON arrays. Map<string, 'T> becomes a JSON object. Tuples become JSON arrays of mixed types, same as the .NET serializers produce.

Can I paste a whole module?

Yes. Every top-level record and union becomes its own JSON entry, with nested records expanded. let-bindings that construct sample values are picked up too — useful when you have a test-data module.

Is my code stored?

Your F# is sent to the backend for conversion and is not persisted — we do not log the payload. For sensitive domain code, review before pasting.

Other tools you may need

F# to JSON is one piece. These pair well with it: