Is there a way to export the contents of org-mode blocks to a text file? The blocks will contain only ascii text.

I can export the contents of a source block using Babel with tangling:

#+BEGIN_SRC  latex :tangle yes
Export this text to a text file.

However, this produces a file of type specified by the language identifier. The language identifier in the example above is latex and therefore the output is a .latex file. Is there a way to export a block to a .txt file?


matteol's solution works. However, the output file will be named out.text. It seems Babel takes the suffix from the language identifier in the header, so replacing text with txt will produce out.txt.

If you want to send the output to a .txt file with the same filename as the source org file, here is a working example:

#+BEGIN_SRC txt :tangle yes
Export this text to a .txt file.

For example if your source file is named my_document.org, the tangled output file will be named my_document.txt.

Because it is possible to export text in the way described, it might be helpful to update the Babel language documentation to reflect this. I don't see an option for txt in list of supported languages.

1 Answer 1


You can specify a file name in the :tangle header argument like this

#+BEGIN_SRC text :tangle out.txt
Export this text to a text file.

See the manual for details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.