> For the complete documentation index, see [llms.txt](https://gaffa.dev/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gaffa.dev/docs/features/browser-requests/actions/generate-simplified-dom.md).

# Generate Simplified DOM

**Type:** `generate_simplified_dom`

When you're looking at the DOM of a web page, there's a lot of unnecessary data that can be discarded if you are only interested in the page's elements or looking to export the data into an LLM.\
\
The `generate_simplified_dom` output format processes the HTML in the following way:

* Removes all links in the `head`
* Removes all `script` nodes and links to scripts
* Removes all `style` nodes
* Remove `style` attributes from all elements
* Remove all links to stylesheets
* Remove all `noscript` elements outside of the body
* Finds all `hrefs` with query strings and removes the query strings
* Important `meta` tags are kept, all others are removed
* Remove all `alternate` links
* Remove all SVG paths
* Remove empty text nodes and excessive spacing

<details>

<summary><strong>Tips for using <code>generate_simplified_dom</code></strong></summary>

* Use this when an agent needs to look at a page and work out what to click or type next. It keeps the classes, IDs and structure that selectors are built from.
* Use it instead of [`capture_dom`](/docs/features/browser-requests/actions/capture-dom.md) for anything going to an LLM. Same structure, far fewer tokens.
* Don't use it to debug styling — styles and stylesheets are removed.
* Note that query strings are stripped from links, so use [`capture_dom`](/docs/features/browser-requests/actions/capture-dom.md) if you're collecting URLs with parameters.

</details>

### Parameters

See [universal parameters](/docs/features/browser-requests/actions.md#universal-parameters).

### Usage

The following JSON captures the page's DOM and simplifies it.

```json
"actions": [
    {
        "type": "generate_simplified_dom"
    }
]
```

{% hint style="info" %}
We are actively working to improve this and to make this process more configurable - let us know if there's something you think we can improve.
{% endhint %}

### Example Output

{% file src="/files/ywz6DNXI6USCGkeInqGv" %}

### **FAQs**

#### When do I use generate\_simplified\_dom?

Use it when you need to understand a page's structure — usually to find selectors on a site you haven't scraped before, or to give an AI agent something to plan its next action from.

#### What does generate\_simplified\_dom remove?

It removes scripts, styles and style attributes, stylesheet and alternate links, noscript elements outside the body, SVG paths, most meta tags, query strings on links, and empty text.

#### When should I use capture\_dom instead of generate\_simplified\_dom?

Use [`capture_dom`](/docs/features/browser-requests/actions/capture-dom.md) when you need something simplification removes — inline scripts, style attributes or full link URLs. Use the simplified version for everything else.

#### When should I use generate\_markdown instead of generate\_simplified\_dom?

Use [`generate_markdown`](/docs/features/browser-requests/actions/generate-markdown.md) when you only need the content. Use `generate_simplified_dom` when you need the structure too, like classes and IDs to build selectors from.

#### How can an AI agent find selectors on a page it doesn't know?

Run `generate_simplified_dom` first, look through the structure for stable IDs, classes or ARIA labels, then build [`click`](/docs/features/browser-requests/actions/click.md), [`type`](/docs/features/browser-requests/actions/type.md) or [`capture_element`](/docs/features/browser-requests/actions/capture-element.md) actions from what you find.

#### Does generate\_simplified\_dom keep links?

Yes, but without their query strings. If you need full URLs with parameters, use [`capture_dom`](/docs/features/browser-requests/actions/capture-dom.md) or [`capture_element`](/docs/features/browser-requests/actions/capture-element.md) instead.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gaffa.dev/docs/features/browser-requests/actions/generate-simplified-dom.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
