Back to CustomJS in Google Sheets
SheetXAI logo
CustomJS logo
CustomJS · Google Sheets Guide

Bulk Convert HTML Strings in a Google Sheet to PDFs Using CustomJS

2026-05-14
5 min read

The Scenario

You inherited this sheet three weeks ago when the person who built the original reporting system went on leave. There are 80 rows. Column A holds an HTML string for each client's monthly report — different header colors, different table structures, same column letter. Your job is to get all 80 converted to PDFs by end of business and their download URLs written into column B so the account team can send them out.

The bad version:

  • Copy the HTML string from A2, hit the CustomJS API in Postman, download the PDF, get the download URL, paste it into B2 — then do it again for A3
  • Realize around row 20 that three of the HTML strings have malformed tags and are returning 400 errors, so you have to open each one, fix the markup, re-run the conversion, and reconcile which rows you've already finished
  • Build a spreadsheet alongside the actual spreadsheet to track which rows are done, which ones errored, and which ones are waiting for a fix

Nobody brought you in to manually operate an API for eight hours. The account team is waiting on links. The time budget for this is not "an afternoon plus debugging."

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Google Sheet. It reads your data, understands what's in each column, and through its built-in CustomJS integration it can run the HTML-to-PDF conversion across every row and write the results back — without you touching a single API call.

Open the SheetXAI sidebar and paste this prompt:

For each HTML string in column A of my sheet, use CustomJS to convert it to a PDF and write the resulting download URL into column B — process all rows with data in column A

What You Get

  • Column B fills with CustomJS download URLs, one per row, aligned with the HTML source in column A
  • Rows that returned conversion errors surface with a note in column B so you can find and fix them without cross-referencing a separate tracker
  • Rows already populated in column B are left alone unless you explicitly ask to overwrite
  • The entire operation runs in one pass — no per-row manual steps

What If the Data Is Not Quite Ready

Some HTML strings have broken tags that cause conversion failures

Before converting, check each HTML string in column A for unclosed tags or missing DOCTYPE declarations and flag any malformed rows in column C with a short description of the issue, then convert the clean rows to PDF and write download URLs to column B

The HTML strings are split across two tabs and need to be combined first

Merge the HTML strings from column A on the "Q1 Reports" tab and column A on the "Q2 Reports" tab into a single list on a new tab called "All Reports," then use CustomJS to convert each one to a PDF and write the download URL to column B of that new tab

Each row should produce a PDF with a filename that matches the client name in column C

For each row in my sheet, use CustomJS to convert the HTML string in column A to a PDF — use the client name in column C as the filename — and write the resulting download URL into column B

Clean up malformed rows, convert everything, and flag anything that still fails

For each row in column A: if the HTML string is missing an opening html tag, add one; then use CustomJS to convert it to a PDF, write the download URL to column B, and if conversion still fails after the fix, write "CONVERSION ERROR" to column B with the status code

When you're dealing with inherited data, the pattern is to ask for cleanup and conversion in a single instruction — not two separate passes.

Try It

Get the 7-day free trial of SheetXAI and open any Google Sheet where column A holds HTML report templates, then ask it to convert and write every URL in one pass. Also worth looking at: merging a list of PDF URLs into one document and the CustomJS overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more