Skip to main content
v2026.11,772 entries · CC-BY 4.0

Direct comparison

SAM vs BAM vs CRAM Compared

SAM, BAM, and CRAM compared: file-size differences, when CRAM’s reference dependency is worth it, and samtools view commands to convert between them.

Written and maintained by CASRAI Editorial Board

Last updated

Ask CASRAI · included with Regulatory Radar

Ask about SAM vs BAM vs CRAM Compared

Ask CASRAI answers research-administration questions and cites the passages behind every claim — and says so when the corpus does not cover something, instead of guessing. It comes with a Regulatory Radar subscription at $29 a month, alongside the daily digest of regulatory changes and the dashboard of what changed.

150 questions a day, on this site, over the API, or inside your own tools through the CASRAI MCP server.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

How do SAM, BAM, CRAM compare side by side?

The table below compares SAM, BAM, CRAM across 11 procurement-relevant dimensions, from encoding through lossless by default?.

Side-by-side comparison

DimensionSAMBAMCRAM
EncodingPlain text, tab-delimitedBinary, BGZF-compressed (block gzip)Binary, reference-based compression with per-field codecs
Human-readableYes — directly greppable/diffableNo — requires samtools/htslib to viewNo — requires samtools/htslib AND the matching reference to view
Self-contained (no external file needed to read it)YesYesNo — needs the exact reference FASTA used to compress it
Typical size vs. equivalent BAMSeveral-fold larger than BAM (uncompressed text)BaselineRoughly 35–70% smaller, platform-dependent (htslib benchmarks: ~66% smaller for Illumina NovaSeq, ~45% for HiSeq 2500, ~73% for PacBio Revio, ~37% for Oxford Nanopore, at default settings)
Indexed random accessNo (not normally indexed)Yes — .bai index on coordinate-sorted filesYes — .crai index on coordinate-sorted files
Risk if the reference becomes unavailable or ambiguousNot applicable — no reference dependencyNot applicable — sequence is stored directlyFile becomes undecodable — not degraded, unreadable — unless the exact reference (matching contig MD5s) is separately archived and retrievable
Best fitDebugging a pipeline, inspecting a small slice of records, or a transient stream between toolsThe default working/interchange format — active analysis, sharing between labs, any workflow needing self-contained safetyLong-term archival storage at scale, where the reference (a standard build like GRCh38/T2T-CHM13, checksummed and durably hosted) is guaranteed stable
Convert with samtools viewsamtools view -b -o aln.bam aln.sam (SAM to BAM)samtools view -C -T ref.fa -o aln.cram aln.bam (BAM to CRAM, -T mandatory)samtools view -b -T ref.fa -o aln.bam aln.cram (CRAM to BAM, same reference required)
Governing specificationSAM/BAM specification, samtools.github.io/hts-specsSame SAM/BAM specification (BAM is its defined binary form)CRAM v3.x specification (current); v2.1 is an obsolete predecessor, both at samtools.github.io/hts-specs
Common file/index extensions.sam (no standard index).bam, indexed as .bam.bai.cram, indexed as .cram.crai
Lossless by default?Yes — no compression applied at allYesYes by default; optional lossy modes (e.g. quality-score binning) exist but must be explicitly enabled

Common questions

Common questions about SAM vs BAM vs CRAM

Do I need the reference genome to open a CRAM file?

+

Yes, and it must be the exact reference used at compression time — matched contig-by-contig via MD5 checksum. Without it, samtools and other htslib-based tools cannot decode the file at all; this is not a slowdown, it is a hard failure. Keep the reference FASTA (and ideally its checksums) archived alongside any CRAM file you intend to read again later.

How much smaller is CRAM than BAM in practice?

+

It depends heavily on sequencing platform and data type. htslib’s published benchmarks on 10 million alignments show CRAM 3.1 files roughly 35–73% smaller than the equivalent default BAM — the largest gains on Illumina short-read and PacBio long-read data, a narrower gain (~37%) on Oxford Nanopore data where quality-score entropy compresses less well. There is no single universal ratio; test on your own data if the number matters for a budget decision.

Is CRAM ever the wrong choice even for archival storage?

+

Yes, when the reference used for alignment is non-standard, unpublished, a lab-specific assembly, or otherwise not guaranteed to be durably retrievable years later. If the reference could become unavailable, get revised without a stable version identifier, or was simply never archived, CRAM trades a real storage saving for a real risk of total data loss. BAM’s self-containedness is worth the extra disk space in exactly that situation.

Can I convert directly from SAM to CRAM, skipping BAM?

+

Yes — samtools view -C -T ref.fa -o aln.cram aln.sam works directly; BAM is not a required intermediate step, it is just the historically dominant intermediate format most pipelines still emit by default.

Does converting to CRAM lose any information?

+

Not by default — samtools’ default CRAM profile is lossless for sequence and alignment data. CRAM does support optional lossy modes (e.g. quality-score binning) for further size reduction, but those are opt-in, not the default, and should only be used when the downstream analysis is known to tolerate reduced quality-score precision.

Which format should a new pipeline standardize on?

+

BAM for anything actively read/written or shared outside a controlled environment where the reference might not travel with the file; CRAM for long-term, high-volume archival where the reference is a well-known, checksummed, durably hosted build. Most production pipelines keep BAM during active analysis and convert to CRAM only at the archival step.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Regulatory Radar

Stop finding out after the fact

$29/month, cancel anytime. Daily digest updates from our analysis, a dashboard holding the same items, and a cited assistant for everything they raise.

  • Federal Register, Federal Register+, Grants.gov, Regulations.gov, NSF News, UKRI, plus CASRAI’s own published content.
  • 72,264 indexed passages, and every answer cites the ones it drew on.