Fetch H1, H2, H3 Tags into Google Sheets with IMPORTXML

Use Google Sheets' IMPORTXML and simple XPath expressions to extract H1, H2 and H3 heading text from a web page into cells for fast SEO auditing and content-structure checks.

What the video covers

Office & Google Workspace

Watch the video on YouTube

Step-by-step instructions

  1. Open or create a Google Sheet
    Open a new or existing spreadsheet in Google Sheets to hold URLs and extracted headings.
  2. Put the target URL in a cell
    Enter the webpage address you want to audit into a cell (for example, A2).
  3. Extract H1 tags
    In the desired output cell (for example, B2) enter: =IMPORTXML(A2, "//h1") and press Enter. The sheet will populate with all H1 text nodes found in that page's HTML.
  4. Extract H2 and H3 tags
    In separate cells enter: =IMPORTXML(A2, "//h2") and =IMPORTXML(A2, "//h3") to pull secondary and tertiary headings respectively.
  5. Optional — show results across columns
    If the IMPORTXML result spills down rows but you want headings across columns, wrap with TRANSPOSE, for example: =TRANSPOSE(IMPORTXML(A2, "//h2")) to lay H2s horizontally.
  6. Optional — add a clean fallback for missing tags
    Wrap the call with IFERROR to show a friendly message instead of an error, e.g.: =IFERROR(IMPORTXML(A2, "//h1"), "No H1 Found").
  7. Scale to multiple pages
    Place each target URL on its own row (e.g., column A) and copy the IMPORTXML formulas across corresponding columns to build a multi-page heading audit sheet. Be mindful of request limits and throttling.

Watch the video

Video thumbnail for Fetch H1, H2, H3 Tags into Google Sheets with IMPORTXML Play tutorial

Watch on YouTube

Why it matters

Manually inspecting page source for headings is slow and repetitive. IMPORTXML lets you pull heading tags directly into your sheet so you can audit page structure, compare pages, or feed headings into further analysis automatically.

Check your result

Successful extraction fills the target cell(s) with the page's H1, H2 or H3 text. If a tag type is absent you should see your fallback text (if you used IFERROR) or a clear error message.

Troubleshooting

– #N/A or empty results: page may be dynamically generated (client-side JavaScript) — IMPORTXML cannot load content created after initial page HTML. Use a server-side scraper or export static HTML instead. – #ERROR or parsing issues: malformed XPath or unexpected HTML. Ensure you use double slashes and lowercase tag names (e.g., //h1). – Access blocked or empty: site may block automated requests or require authentication. Confirm the URL is publicly accessible in a normal browser and not behind login/geo-blocks. – Too many requests: Google may throttle repeated IMPORTXML calls across many URLs — add delays, split into batches, or use an Apps Script solution for large crawls. – Multiple headings appear down rows: use TRANSPOSE to place results across columns instead of down rows, or wrap results in INDEX to pick a specific occurrence.