All protocols

Convert FASTQ to FASTA

Convert FASTQ reads to FASTA with seqkit fq2fa, plus a dependency-free awk one-liner that streams gzipped input.

SSSudipta SardarUpdated July 21, 2026

Prerequisites

  • A FASTQ file (optionally gzipped)
  • seqkit installed for Step 1 (Step 2 needs only awk and zcat, standard on any Unix)

1Convert with seqkit fq2fa

seqkit fq2fa reads the (optionally gzipped) FASTQ and writes FASTA, swapping each "@" header for ">" and dropping the "+" separator and quality lines. It prints nothing to stdout on success, so verify with head -2. Note that seqkit wraps FASTA sequences at 60 columns by default (change with -w), so a read longer than 60 bp spans multiple lines and head -2 shows the header plus the first 60 bases.

bash
seqkit fq2fa reads.fastq.gz -o reads.fasta
head -2 reads.fasta

Expected output

>SRR000001.1
TCAGGGACGGATAGCTCAGTTGGTAGAGCAGAGGACTGAAAATCCTCGTGTCACCAGTTC

2Dependency-free awk one-liner

No seqkit? Each FASTQ record is exactly four lines, so keep line 1 (header) and line 2 (sequence) of every record and drop the rest. substr($0,2) strips the leading "@" so the header can be prefixed with ">"; zcat streams the gzipped input without decompressing to disk. Unlike seqkit, awk leaves each sequence on a single line, so head -2 prints the full read.

bash
zcat reads.fastq.gz | awk 'NR%4==1{print ">"substr($0,2)} NR%4==2{print}' > reads.fasta
head -2 reads.fasta

Expected output

>SRR000001.1
TCAGGGACGGATAGCTCAGTTGGTAGAGCAGAGGACTGAAAATCCTCGTGTCACCAGTTCAAATCTGGTTCG

Troubleshooting

zcat: can't stat: reads.fastq.gz (reads.fastq.gz.Z): No such file or directory (macOS)

macOS ships the BSD zcat, which insists on a .Z extension. Use gzcat instead of zcat, or `gunzip -c reads.fastq.gz | awk 'NR%4==1{print ">"substr($0,2)} NR%4==2{print}' > reads.fasta`.

FASTA headers still start with "@" instead of ">"

The "@" was not stripped. Use substr($0,2) to drop the first character before printing the header, or let seqkit fq2fa handle the conversion automatically.