> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/wemtipsandtricks/tips-and-tricks/extracting-text-from-file.md).

# Extracting text from File

A `.txt` file is one of the most basic file formats for storing text. Extracting text from a `.txt` file is straightforward because it contains plain text without formatting. Unlike extracting text from a Word or PDF file, extracting from `.txt` can be done with an expression instead of a process node.

The following expression will extract the text from the file:&#x20;

```
Base64ToText(ToBase64([Input.Files.File01]))
```

In the above example, `[Input.Files.File01]` represents a text file. This file is first encoded as Base64 text and then converted into a text string usable in the application.

### Example

In the data model, we have a list where we can store files for use in the application. This list holds two key fields: one field stores the actual `.txt` file, and the other is a calculated field that contains the extracted text.

<figure><img src="/files/gYRwBw8OqfWiqZWqXOCO" alt=""><figcaption></figcaption></figure>

The calculated field uses the following expression to extract the text from the file in the same record:

```
Base64ToText(ToBase64([TextFromFile.Files.File]))
```

The next image shows you a basic interaction node that allows users to upload a `.txt` file and display its content. After uploading a `.txt` file a record with a text file is added to the database. A repeater is used to show the file on the left and the text content of the file on the right for each of the uploaded files.&#x20;

<figure><img src="/files/yiYPAPU5snBppY8OkP4C" alt=""><figcaption></figcaption></figure>

The result looks like this:

<figure><img src="/files/fGOJMmrVe5V5ZyH22Tek" alt=""><figcaption></figcaption></figure>

### Extracting text from other files

You can also extract text from `.docx` and `.pdf` files using the 'Extract Text from document' process node. You can read more about that process here: [Extract Text from Document](https://docs.wem.io/platform/wemmodeler/flowcharts/execute-process/changing-files#extract-text-from-document).


---

# 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.wem.io/platform/wemtipsandtricks/tips-and-tricks/extracting-text-from-file.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.
