> ## Documentation Index
> Fetch the complete documentation index at: https://docs.odella.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Text to File Block

> Convert text or markdown into styled document files

## Overview

The Text to File Block transforms plain text or markdown into styled document files. This block is particularly useful for creating professional-looking documents from simple text input. It supports multiple output formats, allowing you to generate files that can be easily shared or further edited in popular document processing applications.

<Frame>
  <img src="https://mintcdn.com/odella/PGZ7enNCqh0mvwj_/block-reference/assets/text_to_file_light.png?fit=max&auto=format&n=PGZ7enNCqh0mvwj_&q=85&s=ad77997d694e37f12bf3a3bae188c5d8" alt="Text to File Block Screenshot" className="block dark:hidden" width="676" height="372" data-path="block-reference/assets/text_to_file_light.png" />

  <img src="https://mintcdn.com/odella/PGZ7enNCqh0mvwj_/block-reference/assets/text_to_file_dark.png?fit=max&auto=format&n=PGZ7enNCqh0mvwj_&q=85&s=7169a9a3d2e7ad5bbccf49fd7402a947" alt="Text to File Block Screenshot" className="hidden dark:block" width="716" height="322" data-path="block-reference/assets/text_to_file_dark.png" />
</Frame>

## Inputs

<ParamField path="text" type="string" required>
  The text to convert to files. The input will be coerced to a string if needed.
</ParamField>

## Outputs

<ResponseField name="files" type="file[]">
  The converted file output in the specified formats.
</ResponseField>

<ResponseField name="duration" type="number">
  The time taken to process the conversion in milliseconds.
</ResponseField>

## Editor Settings

<ParamField path="formats" type="string[]" default={["pdf", "docx"]}>
  The output file formats to generate. Supported formats:

  * pdf: Portable Document Format
  * docx: Microsoft Word Document
</ParamField>

## What is Markdown?

Markdown is a simple way to format text that looks great on any device. It doesn't do anything fancy like change font sizes or colors, but it does make it easy to create:

* **Bold** or *italic* text
* Lists (like this one!)
* Headers of different sizes
* Links to websites
* And more!

You don't need to know markdown to use this block, but if you do, you can create more structured and styled documents easily.

## Example: Creating a PDF Report

1. Add a Text to File block to your flow.
2. Connect a Text block with your report content to the `text` input. You can use markdown formatting if desired.
3. In the block settings, select "PDF" as the Output Format.
4. Run your flow. The block will output a PDF file containing your styled report.

<Frame>
  <img src="https://mintcdn.com/odella/63rQpScaEp0bDpCd/images/text-to-file-example.png?fit=max&auto=format&n=63rQpScaEp0bDpCd&q=85&s=9dc58403907838eab978bcf66ea1f3fa" alt="Text to File Example" width="2482" height="1522" data-path="images/text-to-file-example.png" />
</Frame>

## Error Handling

The block will retry failed attempts with the following behavior:

* Maximum retry time of 5 minutes
* Exponential backoff starting at 500ms up to 5000ms
* Traces failed attempts for debugging
* Aborts if the process is cancelled

Common errors include:

* No Docme endpoint configured in settings
* Empty or missing input text
* API rate limit exceeded (429)
* Internal service errors (500)

<Warning>
  Always ensure your environment is correctly configured with a Docme endpoint and that input text is properly formatted.
</Warning>

## FAQ

<AccordionGroup>
  <Accordion title="Do I need to know markdown to use this block?">
    No, you don't need to know markdown. You can input plain text, and the block will still convert it into a styled document. However, knowing markdown can help you create more structured and formatted documents easily.
  </Accordion>

  <Accordion title="Can I generate multiple file formats at once?">
    Yes, you can select multiple output formats in the block settings. The block will generate a file for each selected format and return them in the output array.
  </Accordion>

  <Accordion title="How does the block handle images or other media in the input text?">
    If you're using markdown and include image links, the block will attempt to download and embed these images in the output files. However, other media types may not be supported, depending on the output format.
  </Accordion>
</AccordionGroup>

## See Also

* [Text Block](/block-reference/data/text)
* [File Block](/block-reference/data/file)
* [Draft Block](/block-reference/draft/draft)
