> For the complete documentation index, see [llms.txt](https://docs.datajet-app.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datajet-app.com/liquid/tags/clear.md).

# clear

Explicitly removes variables from memory to help garbage collection. Use this tag to free up memory after processing large arrays or objects that are no longer needed.

```liquid
{% json products %}
  [
    { "id": 1, "title": "Product 1" },
    { "id": 2, "title": "Product 2" },
    { "id": 3, "title": "Product 3" }
  ]
{% endjson %}

{% assign product_titles = products | map: "title" %}

{% comment %} Process the data... {% endcomment %}
{% log product_titles %}

{% comment %} Clear variables when no longer needed {% endcomment %}
{% clear products, product_titles %}

{% comment %} Variables are now removed from memory {% endcomment %}
{% log products %}
```

Results in following output:

```
["Product 1", "Product 2", "Product 3"]
null
```

#### Syntax

```liquid
{% clear variable_name %}
{% clear var1, var2, var3 %}
```

| Parameter         | Description                             |
| ----------------- | --------------------------------------- |
| `variable_name`   | Name of the variable to clear           |
| `var1, var2, ...` | Multiple comma-separated variable names |

#### Use Cases

**After processing large CSV files:**

```liquid
{% assign all_rows = file_content | split: "\n" %}
{% assign parsed_data = all_rows | parse_csv %}

{% comment %} Process parsed_data... {% endcomment %}

{% clear file_content, all_rows %}
```

**After GraphQL pagination:**

```liquid
{% assign all_products = "[]" | parse %}

{% for page in (1..10) %}
  {% graphql query:products_query as page_result %}
  {% assign all_products = all_products | concat: page_result.products.edges %}
  {% clear page_result %}
{% endfor %}
```

**End of script cleanup:**

```liquid
{% comment %} Clear all large variables before script ends {% endcomment %}
{% clear ALL_PARSED_PRODUCT, ALL_EXIST_SKU, IMPORT_FILES, LOCAL_FILES %}
```

#### Notes

* Removes variables from all scopes (local and global)
* Sets variable to `null` before deletion to assist garbage collection
* No error is thrown if variable doesn't exist
* Useful for long-running scripts that process large datasets


---

# 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://docs.datajet-app.com/liquid/tags/clear.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.
