{"uid":"cap_-wujNYIUAbRWBTDGDet1r","slug":"fastx402-html-heading-tree-extractor-ad2202ec","name":"FastX402 HTML Heading Tree Extractor","description":"200 pay-per-call tools for AI agents, from $0.001 per request in USDC on Base or Solana with x402. No account, no API key.","url":"https://fastx402.tools/html-heading-tree?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["html"],"properties":{"html":{"type":"string","description":"HTML document or fragment to extract headings from"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"headings":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"text":{"type":"string"},"depth":{"type":"integer"},"level":{"type":"integer"},"children":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"text":{"type":"string"},"depth":{"type":"integer"},"level":{"type":"integer"},"children":{"type":"array","items":{"type":"object","properties":{"text":{"type":"string"},"depth":{"type":"integer"},"level":{"type":"integer"},"children":{"type":"array","items":{}}}}}}}}}}}}}}}}},"responseSchema":{"type":"json","example":{"headings":[{"id":"intro","text":"Introduction","depth":0,"level":1,"children":[{"id":"bg","text":"Background","depth":1,"level":2,"children":[{"text":"History","depth":2,"level":3,"children":[]}]},{"text":"Methods","depth":1,"level":2,"children":[]}]},{"text":"Conclusion","depth":0,"level":1,"children":[]}]}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_ujh4NqpAcrqbkAxqVDXTG","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Parses an HTML document or fragment and returns a nested tree of all heading elements (h1–h6) with their text, level, depth, id, and hierarchical children.","exampleAgentPrompt":"Can you extract all the headings from this HTML and give them back to me as a nested tree? Here's the HTML: '<h1>Introduction</h1><h2>Background</h2><h3>History</h3><h2>Methods</h2><h1>Conclusion</h1>'","exampleUseCases":[{"title":"Table of contents generation","prompt":"I have this full HTML page and I need to generate a table of contents from its headings — can you pull out all the h1 through h6 tags and return them in a nested tree structure? Here's the HTML: '<article><h1 id=\"main\">Guide to APIs</h1><h2 id=\"basics\">Basics</h2><h3>Auth</h3><h2 id=\"advanced\">Advanced</h2></article>'"},{"title":"Document outline for accessibility audit","prompt":"Take this HTML fragment and extract its heading hierarchy so I can check whether the heading levels are structured correctly for accessibility: '<div><h1>Report</h1><h3>Summary</h3><h2>Details</h2><h4>Notes</h4></div>'"},{"title":"Navigation menu generation from blog post","prompt":"Here's the raw HTML of a blog post — pull out all the headings as a nested tree with their ids and text so I can build a sidebar navigation menu from them: '<h1 id=\"top\">Machine Learning Basics</h1><h2 id=\"supervised\">Supervised Learning</h2><h3 id=\"regression\">Regression</h3><h2 id=\"unsupervised\">Unsupervised Learning</h2>'"}],"resultDescription":"Returns a JSON object containing a 'headings' array of nested heading nodes. Each node includes: 'text' (heading content), 'level' (h1=1 through h6=6), 'depth' (nesting depth starting at 0 for top-level), 'id' (the element's HTML id attribute if present), and 'children' (array of sub-heading nodes with the same structure). The tree mirrors the hierarchical document outline implied by the HTML heading tags.","failureModes":["Missing or empty 'html' query parameter — API returns an error requiring the field","HTML with no heading elements — returns an empty headings array","Malformed HTML — parser may produce unexpected or empty tree depending on severity","Very large HTML documents may time out or exceed request limits","Non-UTF-8 encoded HTML may cause parsing errors"],"whenToPreferThis":"Choose this endpoint when you need a structured, hierarchical tree representation of headings from raw HTML — not just a flat list. It is ideal for generating tables of contents, building navigation menus, auditing document structure, or analyzing heading hierarchy. Prefer this over manual regex approaches when you need proper nesting with depth and id metadata. Pay-per-call with no account or API key required makes it ideal for one-off agent tasks.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-20T12:35:33.924Z","isFirstParty":false,"canonicalSlug":"fastx402-html-heading-tree-extractor-ad2202ec"}