How to use the OpenAI b64_json Builder tool
- Select Image file and choose a PNG, JPEG, GIF or WebP file up to 20 MiB.
- Select Build JSON to encode the image.
- Review the object in the Result box. The image is in the b64_json field of the first data item.
- Select Copy, or use the Download link to save the object as payload.json.
What a b64_json response looks like
Image generation endpoints can return the picture inline. The response then holds a data array, and each element has a b64_json string containing the image file as standard Base64. The client decodes that string and writes the bytes to disk. The alternative is a temporary URL, which needs a second request.
This tool builds the smallest object with that shape from a file you already have. It reads the file, encodes the bytes without line breaks or a data URL prefix, and prints the result as indented JSON. The sample below is the real output for a 70-byte PNG of 1 by 1 pixel.
{
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
}
]
}Image checks and limits in the builder
The file type is decided from the first bytes of the file, not from its name. A renamed text file is refused even if it ends in .png. Only the signature is checked: the tool does not decode pixels, so a truncated image with an intact header still passes.
- PNG: the 8-byte signature that begins with 0x89 followed by the letters PNG.
- JPEG: the bytes FF D8 FF.
- GIF: the text GIF87a or GIF89a.
- WebP: RIFF at offset 0 and WEBP at offset 8.
- Anything else stops with Expected PNG, JPEG, GIF or WebP bytes.
- Files over 20 MiB, or running without a file, give Choose a file up to 20 MiB.
Using the output for mocks and test fixtures
The main use is testing code that consumes image generation results without spending credits or waiting for a model. Save payload.json next to your tests, return it from a stubbed HTTP client or a local mock server, and assert that your code decodes and stores the image correctly. Because you pick the source file, you can cover edge cases on purpose: a large PNG, an animated GIF or a tiny placeholder.
The object contains only the data array with one item. Real responses may include other fields, such as a created timestamp or usage details. Add them by hand if your parser requires them, and duplicate the array item to simulate several images.
How it differs from the vision payload builder
Both tools Base64-encode an image, but they face opposite directions. This one imitates what an image API sends back: bare Base64 in b64_json, with no media type. The OpenAI Vision Payload Builder creates what you send to a chat model: a request with a model name, a prompt and the image as a data URL that states its type. Pick the builder according to your goal: faking a response or preparing a request.
Frequently asked questions
Does this tool call the OpenAI API or upload my image?
No to both. It never contacts an API and needs no key. It converts a file on your device into JSON text with the field layout that image endpoints use for inline results.
Does b64_json include a data URL prefix?
No. The field holds bare Base64 with no data:image/png;base64, header and no line breaks. To show the image in a browser you must add that prefix yourself, using the correct media type for the file.
How do I turn b64_json back into an image file?
Base64-decode the string and write the bytes to a file with the right extension. In Python that is base64.b64decode followed by a binary write. On this site, the Vision Payload Decoder accepts the whole JSON object and offers the image as a download.
How big will the JSON be?
Four thirds of the image size plus about 50 characters of JSON structure. A 3 MB image produces a payload near 4 MB. The upper bound is the 20 MiB input limit, which yields roughly 28 million characters.