When you try to convert HTML to PDF using the API, you get a “malformed JSON” error.
This typically happens during the setup of your request payload — especially when passing raw HTML code into the "html" field of your JSON body.
Why This Happens
The issue might occur because of unescaped double quotes (") inside your HTML code, which conflict with JSON formatting rules. JSON itself uses double quotes to define strings, so any additional unescaped quotes can break the structure and cause parsing errors.
How to Fix It
To resolve this issue, you need to properly escape or replace the conflicting double quotes within your HTML string.
Fix Option 1: Use Escape Characters
Add a backslash (\) before each double-quote (") inside the HTML value.
Correct
{
"html": "<img src=\"https://url\" />"
}
Incorrect
{
"html": "<img src="https://url" />"
}
Fix Option 2: Use Single Quotes Inside HTML
Swap inner double quotes with single quotes ('), keeping the outer ones for JSON.
Correct
{
"html": "<img src='https://url' />"
}
Special Case: Double Quotes Inside Text
If you're including double quotes inside a sentence, replace them with " to avoid breaking JSON.
Incorrect
{
"html": "This is a "Test"."
}
Correct
{
"html": "This is a "Test"."
}
Platform-Specific Related Resources
Make/Integromat: HTML to PDF in Make
Other Integrations: Contact us for guidance on specific platforms.
Helpful Tips
Validate your JSON before sending the request.
When using external editors or automation tools, preview the payload to ensure quotes are escaped.
For bulk processing, try "async": true to avoid timeout errors.