How to make a FASTA file

Four ways to build one, from Notepad to the command line

12 min

DNA helix and pen beside a FASTA file with its header and sequence labeled.

To make a FASTA file, write a header line that starts with > followed by a sequence name, put the sequence on the next line, and save the file as plain text with a .fasta or .fa extension. Repeat the header and sequence for every additional sequence in the same file. If your sequences are already in a text document, a Word file, or a spreadsheet, the TXT to FASTA converter writes the headers for you and downloads a ready .fasta file.

A minimal FASTA file with two protein sequences looks like this:

Text
>INS_HUMAN Insulin
MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPL
ALEGSLQKRGIVEQCCTSICSLYQLENYCN
>GLUC_HUMAN Pro-glucagon
MKSIYFVAGLFVMLVQGSWQRSLQDTEEKSRSFSASQADPLSDPDQMNEDKRHSQGTFTSDYSKYLDSRRAQDFVQWLMN
TKRNRNNIAKRHDEFERHAEGTFTSDVSSYLEGQAAKEFIAWLVKGRGRRDFPEEVAIVEELGRRHADGSFSDEMNTILD
NLAARDFINWLIQTKITDRK

The format dates to the FASTA sequence comparison programs described by Pearson and Lipman in 1988.[1] It survived because it is almost nothing: text that any program can read, which is why BLAST, aligners, and structure predictors such as AlphaFold2 all accept it.

FASTA format rules

A FASTA record has two parts. The header, or definition line, is a single line that begins with >. The first word after > is the sequence identifier; anything after the first space is a free-text description. NCBI asks for identifiers that are unique within the file, contain no spaces, and stay at 25 characters or fewer.[2] In a database download that first word is the accession, so >NM_000207.3 Homo sapiens insulin (INS), mRNA names the sequence NM_000207.3, and that is the name most tools carry into their output.

The sequence follows on the next lines in one-letter codes. Lines can be any length, but NCBI recommends no more than 80 characters per line, and 60 is also common.[2] BLAST reads lowercase letters as uppercase and does not allow blank lines in the middle of the input.[3] A new > line starts the next record, so one file can hold any number of sequences, often called a multi-FASTA file.

PartExampleWhat to check
Header>NM_000207.3 Homo sapiens insulin (INS), mRNAStarts with >, one line, unique first word
SequenceAGCCCTCCAGGACAGGCTGCATCAGAAGAGLetters only, no numbers or spaces
Fileinsulin.fastaPlain text, .fasta, .fa, .fna (nucleotides), or .faa (proteins)

Which characters a FASTA sequence can contain

The letters come from the IUPAC codes. For nucleotides these include ambiguity codes for positions where more than one base is possible, standardized by the IUB nomenclature committee in 1985,[4] and for proteins the one-letter amino acid codes. The table lists what BLAST accepts. BLAST also asks for any digits to be removed or replaced with N for an unknown base or X for an unknown amino acid.[3]

CharacterMeaningSequence type
A C G TAdenine, cytosine, guanine, thymineNucleotide
UUracil in RNA, selenocysteine in proteinsBoth
R YPurine (A or G), pyrimidine (C or T)Nucleotide
S W K MStrong (G or C), weak (A or T), keto (G or T), amino (A or C)Nucleotide
B D H VAny base except A, C, G or T, in that orderNucleotide
NAny baseNucleotide
ACDEFGHIKLMNPQRSTVWYThe 20 standard amino acidsProtein
B ZAspartate or asparagine, glutamate or glutamineProtein
XAny amino acidProtein
*Translation stopProtein
-Gap of indeterminate lengthBoth

Gaps belong in alignments rather than single sequences, and the BLAST web form rejects - in a query; it asks for a run of N or X instead.[3]

Case can carry meaning. Reference genomes from UCSC are soft-masked: repeats found by RepeatMasker and Tandem Repeats Finder are written in lowercase and the rest in uppercase.[5] Most tools read both cases as the same base, but converting such a file to uppercase throws away the repeat annotation.

FASTA file extensions

The format does not require any extension. .fasta and .fa are generic, .fna marks nucleotide sequences and .faa protein sequences, and annotation pipelines add their own: Prokka, for example, writes .ffn for the nucleotide sequences of predicted genes and RNAs, and .fsa for contigs prepared for GenBank submission.[6] Programs read the content, not the name, although upload forms often filter by extension.

How to create a FASTA file in Notepad or TextEdit

Any plain-text editor works; a word processor does not, unless you force plain text.

Windows (Notepad)

  1. Open Notepad and type or paste the header line and the sequence.
  2. Click File, then Save as.
  3. Set Save as type to All files (*.*).
  4. Name the file sequences.fasta and set Encoding to UTF-8.
  5. Click Save.

If Save as type stays on Text documents (*.txt), Notepad saves sequences.fasta.txt. Windows hides known extensions by default, so the file still looks like sequences.fasta in File Explorer. To see the real name, turn on file name extensions (in Windows 11, View, then Show, then File name extensions).

Mac (TextEdit)

  1. Open TextEdit and click Format, then Make Plain Text, before pasting anything.
  2. Type or paste the header line and the sequence.
  3. Click File, then Save, and name the file sequences.fasta.
  4. If TextEdit asks which extension to use, click Use .fasta.

Skipping step 1 saves a rich-text .rtf file with hidden formatting codes that sequence tools can't read.

The same applies to other editors. VS Code, Notepad++, Sublime Text, and BBEdit all save plain text, so only the file name matters.

How to convert text, Word, or Excel data to FASTA

Typing headers by hand is fine for one or two sequences. For more, or for text copied from papers and lab notebooks, converting is faster and avoids stray characters.

For sequences in a text file or notes, paste them into TXT to FASTA. A line such as Human insulin above a sequence becomes its header, wrapped lines are joined, and position numbers and spacing copied from GenBank or UniProt pages are removed. Unnamed lines become >seq_1, >seq_2, and so on. For example:

Text
BRCA1 fragment
        1 atggatttat ctgctcttcg cgttgaagaa gtacaaaatg tcattaatgc
       51 tatgcagaaa atcttagagt

converts to:

Text
>BRCA1 fragment
ATGGATTTATCTGCTCTTCGCGTTGAAGAAGTACAAAATGTCATTAATGCTATGCAGAAAATCTTAGAGT

For a Word document, upload the .docx file to the same converter or copy its text in. Word inserts characters you can't see, such as non-breaking spaces, soft hyphens, and curly quotes, and pasting them into a FASTA file by hand is a common reason tools reject it; the converter removes them.

TXT to FASTA converterPaste or upload DNA, RNA, or protein text and download FASTA. Sequence names, wrapped lines, and tables are detected automatically, and nothing leaves your browser.Open tool

For a spreadsheet with a name column and a sequence column, copy the two columns from Excel or Google Sheets and paste them into TXT to FASTA, or export a CSV and use CSV to FASTA when you need to pick specific columns or add a header prefix. The reverse, turning FASTA into a spreadsheet, is FASTA to CSV.

CSV to FASTAConvert CSV or TSV sequence tables to FASTA with automatic delimiter detection and column mapping.Open tool

For another sequence file format, such as GenBank, EMBL, FASTQ, or a Clustal or PHYLIP alignment, the FASTA converter detects the format and writes FASTA with the original accessions or sequence names as headers.

How to download a FASTA file from NCBI or UniProt

You don't need to build a FASTA file for a published sequence. On an NCBI Nucleotide or Protein record, choose Send to, then File, set Format to FASTA, and create the file; the header carries the versioned accession and the record title. The GenBank view of the same record contains annotation and a feature table instead, and GenBank to FASTA can extract the full sequence, individual coding sequences, or their protein translations from it. For scale, GenBank holds billions of sequence records, all available in FASTA; the GenBank statistics guide has current counts.

On a UniProt entry, the Download button offers FASTA directly. UniProt headers follow a fixed pattern, >db|accession|entry name, then the protein name and fields such as OS= (organism), OX= (taxonomy ID), GN= (gene name), PE= (protein existence), and SV= (sequence version).[7]

Text
>sp|P01308|INS_HUMAN Insulin OS=Homo sapiens OX=9606 GN=INS PE=1 SV=1

How to make a FASTA file on the command line

When the sequences are already in a text file, one command writes the FASTA. A file with one sequence per line becomes numbered records with awk:

Bash
awk '{print ">seq_" NR "\n" $0}' sequences.txt > sequences.fasta

A tab-separated file with the name in the first column and the sequence in the second becomes named records:

Bash
awk -F'\t' '{print ">" $1 "\n" $2}' primers.tsv > primers.fasta

For larger jobs, SeqKit converts, rewraps, deduplicates, and summarizes FASTA files.[8] seqkit tab2fx turns the same two-column table into FASTA, and seqkit seq -w 60 rewraps an existing file to 60 characters per line. On any FASTA file, seqkit stats reports the number of sequences and their lengths, a quick check that nothing was lost.

Common mistakes that break FASTA files

Most rejected FASTA files fail for one of a handful of reasons, and most of them are invisible in the editor.

ProblemSymptomFix
Hidden .txt extensionUpload dialogs don't list the file, or the tool reports the wrong formatShow file extensions and rename to .fasta
Rich text (.rtf, .docx) saved as FASTAUnreadable characters or formatting codes in the outputSave as plain text, or convert the document text
Numbers or spaces in the sequenceValidation errors, or wrong sequence lengthsRemove position numbers and grouping spaces
Blank lines inside the fileRecords are dropped, or the file is rejectedDelete empty lines between and within records
Missing > or header over two linesThe name is read as sequenceKeep each header on one line starting with >
Duplicate identifiersDatabase builders such as makeblastdb fail, or results overwrite each otherMake the first word of every header unique
Spaces or special characters in the identifierThe identifier is cut at the first spaceUse underscores, for example >BRCA1_exon2
Windows line endings in Unix toolsA stray \r in names or errors about invalid charactersSave with LF endings, or run sed 's/\r$//' in.fasta > out.fasta
Stop * or gap - charactersRejected by tools that expect letters only, including the BLAST web form for -Remove them unless the tool accepts alignments or stops

The converters on ProteinIQ fix the sequence-level problems automatically and tell you what they changed, such as a removed stop codon or skipped line of text, so check the notices before using the file.

After you have the FASTA file

A FASTA file is usually a starting point. Protein sequences can go straight into structure prediction with ESMFold or AlphaFold2, several related sequences into multiple sequence alignment with Clustal Omega, and DNA into GC content analysis or translation with DNA to protein. Large files can be divided with the FASTA splitter when a tool limits the number of sequences per job. The sequence alignment use case walks through a complete workflow from FASTA input to aligned output.

FAQ

What is the difference between .fasta, .fa, .fna, and .faa?

They are all the same format. .fasta and .fa are generic, .fna marks nucleotide sequences, .faa amino acid sequences, and .ffn the nucleotide sequences of predicted genes in annotation output. Tools read the content, so any of them works.

What is the difference between FASTA and FASTQ?

FASTQ adds a quality score to every base. Each record takes four lines: a header starting with @, the sequence, a + separator line, and a string of characters as long as the sequence, where each character encodes the Phred quality of the base above it. In the standard Sanger encoding, the character's ASCII code minus 33 gives Q=−10log⁡10PQ = -10 \log_{10} P, so I means Q40, a 1 in 10,000 chance that the base call is wrong.[9]

Sequencers write raw reads as FASTQ, and read mappers and assemblers expect it. FASTA is for finished sequences such as references, assemblies, genes and proteins, which have no per-base quality. FASTQ to FASTA drops the quality lines, and FASTA to FASTQ adds placeholder scores for tools that only accept FASTQ. How much those scores are worth on real instruments is covered in DNA sequencing accuracy.

What is the difference between GenBank and FASTA?

A GenBank flat file is a full database record. It starts with a LOCUS line and fields such as DEFINITION, ACCESSION and SOURCE, lists annotated genes, coding sequences and other features in a FEATURES table, and only then gives the sequence after ORIGIN, in numbered lines of 60 bases, ending with //.[10]

A FASTA record keeps just one header line and the sequence. Use GenBank when you need coordinates of genes or translations, and FASTA when a tool only needs the sequence. GenBank to FASTA converts one to the other, and the GenBank feature extractor pulls out individual features.

Can I save a FASTA file as .txt?

The content can be identical, but many upload forms filter by extension. Rename the file to .fasta or .fa so tools recognize it.

Does a FASTA file need line breaks every 60 or 80 characters?

No. One line per sequence is valid. Wrapping at 60 or 80 characters is a convention that keeps files readable, and NCBI recommends no more than 80.

How do I put several sequences in one FASTA file?

Write each sequence under its own > header in the same file. A file with several records is often called multi-FASTA.

Is there a FASTA file generator online?

Yes. TXT to FASTA generates a FASTA file from pasted text, a Word document, or spreadsheet rows, and the FASTA converter creates one from GenBank, FASTQ, and alignment files. Both run in the browser without an account.