Decode a Base64 file field from a JSON API response
Extract the file field, parse JSON escapes and restore the three bytes 00 FF 41. Keep the filename separate from the data you decode.
Locate the binary field in the response
JSON has no dedicated file type, so an API may represent bytes as a string. In this example, name holds the filename and data holds the Base64. Check the actual field contract for the key name and whether it uses standard Base64 or the URL-safe alphabet.
Parse the JSON and restore the bytes
This Node.js example prints 3 00ff41. JSON.parse handles the surrounding quotes and JSON escapes. To compare with the website, save AP9B alone in a text file and use file decoding. Byte FF on its own is invalid UTF-8, making a text preview a poor comparison here.
const body = JSON.stringify({name: "swatch.bin", data: "AP9B"});
const record = JSON.parse(body);
const bytes = Buffer.from(record.data, "base64");
console.log(bytes.length, bytes.toString("hex"));Preserve the other response fields
If the JSON source contains an escaped slash, parse the record before inspecting the value. Stripping quotes and backslashes from the whole response can alter unrelated fields. The filename and media type are metadata, so keep them separately when writing the decoded bytes.