Skip to main content

Base64 Image

When converting an image to Base64 for API requests, you must remove the data: scheme and media type prefix (e.g., data:image/jpg;base64,).

Example

// Example: Remove the prefix from a Base64 string
const base64StringWithPrefix = "data:image/jpg;base64,...";
const base64String = base64StringWithPrefix.split(",").pop();

// Now 'base64String' contains only the Base64 encoded data
console.log(base64String);

Using AIGEN Dev Tool

For convenience, you can use AIGEN's development tool to convert images to Base64 format:

🔗 AIGEN Dev Tool - Base64 Encoder/Decoder