ESMFold for Beginners: How to Predict Protein Structures in Seconds
By Dr. Zubair Khalid, DVM, MS, PhD ·

By the end of this ESMFold tutorial you will be able to take any protein sequence, submit it to ESMFold through a public API or on your own machine, receive a 3D coordinate file in PDB format, and judge how much of that model you should actually trust. You will also learn the failure modes that trip up most first-time users, because a confident-looking prediction can still be wrong.
To follow along you need three things:
- A protein sequence in FASTA format. This tutorial uses green fluorescent protein (GFP) as the worked example.
- A terminal with
curlor a Python 3 environment. Nothing else is required for the web-based method. - Optionally, a CUDA GPU with recent PyTorch if you want to run ESMFold locally instead of through the API.
Some context helps explain why this matters. At the 14th Critical Assessment of Structure Prediction (CASP14), AlphaFold2 reached a median Global Distance Test (GDT) score of 92.4 across 87 of 92 evaluated domains, a result John Moult described as solving the protein structure prediction problem for single protein chains after more than five decades of effort [1]. The AlphaFold Protein Structure Database now holds approximately 214 million predicted structures covering nearly the entire protein universe of known sequences [1]. Those resources cover enormous ground, but when your protein is missing from the database, or when you are designing or screening many new sequences, you need on-demand prediction. ESMFold gives you that on demand, and it does so without the slow database searches that AlphaFold-style pipelines require.
What ESMFold Is and How It Differs From AlphaFold
ESMFold is a structure prediction system from Meta AI that converts a single protein sequence directly into atomic coordinates. To understand why it is fast, you need to understand what it skips.
AlphaFold2, the method behind most AlphaFold tutorials you will find online, relies on a multiple sequence alignment (MSA). An MSA collects evolutionarily related sequences from large reference databases, and the co-variation of residues across those homologs tells the network which amino acids contact each other in space. Building and searching MSAs is the slowest part of every AlphaFold pipeline, often taking hours per protein and requiring access to terabyte-scale sequence databases.
ESMFold replaces the MSA with a protein language model. A language model, in this context, is a neural network trained on millions of unaligned sequences to predict missing residues from context. Meta's ESM-2 model, whose largest version has roughly 15 billion parameters, learns evolutionary and structural patterns directly from raw sequence data, so ESMFold can fold a protein from its sequence alone. The practical consequences for beginners are significant:
- Speed. Typical single-chain predictions finish in seconds to a few minutes rather than hours, depending on sequence length and hardware.
- Simplicity. No sequence databases to download, no MSA generation step, no dependency on remote alignment services.
- Modest accuracy trade-off. On benchmarks, MSA-based methods such as AlphaFold2 remain the reference standard, and ESMFold can be less accurate for proteins with shallow evolutionary histories or unusual folds. For routine single-chain work the quality is usually close enough to be useful.
The broader ecosystem matters too. The AlphaFold Protein Structure Database, hosted by EMBL-EBI, lets you search for your protein by UniProt identifier before predicting anything, and DeepMind operates a web-based AlphaFold Server for AlphaFold 3 predictions of complexes and modified components, with daily usage limits for noncommercial research. This ESMFold tutorial covers the complementary case: you have a sequence in hand and you want coordinates back in seconds, unattended, at scale.
What You Need Before You Start

ESMFold predicts one polypeptide chain at a time. A residue is a single amino acid unit in the chain, and sequences are written as one-letter codes: A for alanine, M for methionine, and so on. The standard container for a sequence is FASTA format, a plain-text format with a header line beginning with > followed by the sequence itself:
>sp|P42212|GFP_AEQVI Green fluorescent protein
MSKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTL
Before submitting anything, check the following:
- Use uppercase one-letter codes for the 20 standard amino acids. Strip stop characters (
*), spaces, and numbering digits. - Know your sequence length in residues. Short sequences behave differently from long ones, as you will see in the limitations section.
- Decide where the sequence will be processed. A public API is convenient, but your unpublished sequences leave your machine. For confidential work, run locally.
For viewing results, install a molecular viewer. PyMOL and ChimeraX are the two most common choices in structural biology labs, and both can color a model by its per-residue confidence values.
Method 1: Predict a Structure Through the Public API (No Installation)

The fastest route for ESMFold beginners is the public folding endpoint documented in the Meta ESM GitHub repository. You send a plain protein sequence by HTTP POST and receive PDB text back. An API (application programming interface) is a web address a program can call to run a service remotely.
Step 1: Prepare a plain sequence file
The API wants the sequence letters only, no FASTA header. Create sequence.txt containing nothing but the residues:
MSKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKQHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYIMADKQKNGIKVNFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITLGMDELYK
That is the full 238-residue GFP sequence, which I am using because it is short, well studied, and has many experimental structures to compare against. If you are starting from a FASTA file, strip the header line first.
Step 2: Send the sequence
From a terminal:
curl -X POST https://api.esmatlas.com/foldSequence/v1/pdb/ -H "Content-Type: text/plain" -d @sequence.txt -o gfp_esmfold.pdb
Each flag matters. -X POST selects an HTTP POST request, which sends data to the server rather than requesting a page. -H sets the content type so the server reads the body as plain text. -d @sequence.txt attaches your sequence file as the request body. -o writes the response to a file instead of the terminal.
The equivalent in Python, which is easier to build pipelines around:
import requests
sequence = open("sequence.txt").read().strip()
response = requests.post(
"https://api.esmatlas.com/foldSequence/v1/pdb/",
data=sequence,
)
response.raise_for_status()
with open("gfp_esmfold.pdb", "w") as f:
f.write(response.text)
Step 3: Check what came back
Open gfp_esmfold.pdb. A PDB file is a plain-text format describing atomic coordinates. Expect lines like this:
ATOM 1 N MET A 1 -7.952 -4.219 6.118 1.00 89.15 N
ATOM 2 CA MET A 1 -6.735 -3.466 5.741 1.00 90.02 C
Two things to notice. First, the number in the second-to-last numeric column, the B-factor field, is not a crystallographic B-factor here. ESMFold writes the per-residue confidence value, called pLDDT, into that column. Second, if the response is empty or the server returns an error, the endpoint may have moved or be rate limited. The ESM GitHub repository documents the current address, so check there before debugging your own code.
This method is genuinely a predict-in-seconds workflow for sequences of a few hundred residues. For sequences of thousands of residues, requests can time out, which is the main reason to move to local inference.
Method 2: Running ESMFold Locally
Local execution gives you batch processing, pTM scores in addition to pLDDT, no data leaving your machine, and no dependence on a service that might change. The cost is a heavier installation.
Step 1: Install the ESM package
ESMFold ships inside Meta's fair-esm Python package with an optional folding extra:
pip install "fair-esm[esmfold]"
The folding head depends on modules from OpenFold, an open reimplementation of AlphaFold2 components. Install OpenFold from the exact pinned commit listed in the ESM GitHub repository README rather than from the latest version, because the interface between the two packages is version sensitive. A CUDA-capable GPU with recent PyTorch is strongly recommended. On CPU-only machines, inference is dramatically slower and very long sequences may not fit in memory at all.
Step 2: Download the model
Model weights download automatically the first time you load the model. They are several gigabytes and land in your PyTorch hub cache directory, so run the first load on a machine with disk space and a stable connection:
import esm
model = esm.pretrained.esmfold_v1()
model = model.eval().cuda()
esmfold_v1() loads the released ESMFold weights built on the large ESM-2 language model. .eval() switches the network to inference mode, and .cuda() moves it to the GPU.
Step 3: Predict
import torch
sequence = "".join(
line.strip()
for line in open("gfp.fasta")
if not line.startswith(">")
)
with torch.no_grad():
output = model.infer_pdb(sequence)
with open("gfp_local.pdb", "w") as f:
f.write(output)
print("done")
The torch.no_grad() context disables gradient tracking, which saves memory during inference. infer_pdb runs the full pipeline and returns the coordinates as a PDB-format string ready to write to disk. For a 238-residue protein on a modern GPU this call returns within seconds to a few tens of seconds. Runtime grows nonlinearly with length, so a 2,000-residue protein takes far more than ten times as long as a 200-residue protein.
If you call the lower-level model.infer method instead, the returned dictionary also carries a pTM value, accessible as output["ptm"], which estimates the confidence in the overall fold rather than in individual residues.
Step 4: Process many sequences
For a batch of proteins, loop over a FASTA file with Biopython:
from Bio import SeqIO
import torch
model = esm.pretrained.esmfold_v1()
model = model.eval().cuda()
for record in SeqIO.parse("targets.fasta", "fasta"):
seq = str(record.seq)
with torch.no_grad():
pdb_string = model.infer_pdb(seq)
with open(f"{record.id}.pdb", "w") as f:
f.write(pdb_string)
print(record.id, "predicted")
Save the model object outside the loop so the weights load once. Expect GPU memory, not processor speed, to be the limiting factor for long chains.
Reading the Output: pLDDT, pTM, and the Confidence Table
Every residue in the output carries a pLDDT score, short for predicted local distance difference test. This is a per-residue number on a 0 to 100 scale estimating how accurately that residue is placed. The convention, inherited from AlphaFold and used identically in ESMFold output, divides the scale into four bands.
| pLDDT range | Interpretation | What to do with it |
|---|---|---|
| 90 to 100 | Very high backbone accuracy | Treat side-chain and backbone geometry as reliable for most purposes |
| 70 to 90 | Confident backbone, less certain side chains | Fine for domain-level and fold-level conclusions |
| 50 to 70 | Low confidence | Inspect carefully, do not over-interpret contacts |
| Below 50 | Very low confidence | Often intrinsically disordered, treat coordinates as uninformative |
Three habits make these numbers meaningful:
- Look at the distribution, not just the mean. A protein with a mean pLDDT of 85 can be excellent in a 150-residue core and garbage in a 60-residue terminal tail. Compute per-residue values and see where the dips are.
- Color the model by confidence. In PyMOL, load the file and run:
load gfp_esmfold.pdb
show cartoon
spectrum b, blue_white_red, minimum=50, maximum=90
The spectrum b command maps the B-factor column, which holds pLDDT, onto a color gradient. In ChimeraX, the built-in AlphaFold color preset under the Presets menu applies the same blue-to-red banding scheme. Very low confidence regions are conventionally drawn in dark red or dark blue depending on the scheme, and they almost always correspond to flexible or disordered segments.
- Distinguish pLDDT from pTM. pTM, the predicted template modeling score, estimates confidence in the global fold on a 0 to 1 scale. A local region can be well placed while the overall domain arrangement is uncertain, and vice versa. Check both when the conclusion you care about involves how domains sit relative to each other.
A quick command-line summary of per-residue confidence, taking one value per residue by filtering on the C-alpha atoms:
import statistics
plddt = [
float(line[60:66])
for line in open("gfp_esmfold.pdb")
if line.startswith("ATOM") and line[12:16].strip() == "CA"
]
print("residues:", len(plddt))
print("mean pLDDT:", round(statistics.mean(plddt), 1))
print("residues below 50:", sum(p < 50 for p in plddt))
For a compact, mostly folded protein such as GFP, most residues should sit in the top two bands. Large fractions below 50 usually mean disorder, a misannotated construct, or a sequence the model genuinely cannot resolve.
ESMFold Tutorial Step by Step: A Complete Worked Example
This section strings everything together into a single esmfold tutorial step by step run you can reproduce in under ten minutes, using GFP as the test case.
- Check whether a structure already exists. Search the AlphaFold Protein Structure Database at the EMBL-EBI site for your UniProt identifier, and search the RCSB Protein Data Bank for experimental structures. GFP has dozens of crystal structures, so in this case prediction is a learning exercise rather than a necessity. Make this check a reflex, because experimental data always outranks a prediction.
- Download the reference sequence. UniProt, the curated protein sequence database, offers a simple REST interface:
curl -o gfp.fasta "https://rest.uniprot.org/uniprotkb/P42212.fasta"
cat gfp.fasta
The output is a header line beginning >sp|P42212|GFP_AEQVI followed by the 238-residue sequence.
- Validate the sequence. Confirm the length is 238, confirm every character is one of the 20 standard letters, and confirm there is no
*stop symbol:
valid = set("ACDEFGHIKLMNPQRSTVWY")
seq = "".join(
line.strip() for line in open("gfp.fasta") if not line.startswith(">")
)
assert set(seq.upper()) <= valid, "non-standard residue found"
print(len(seq))
- Predict. Use either the API call from Method 1 or the local code from Method 2. On a GPU, the local run completes in seconds for this length.
- Inspect the PDB file. Count ATOM records, confirm the residue numbering runs from 1 to 238, and confirm the B-factor column carries values in the 0 to 100 range rather than small crystallographic values.
- Summarize and visualize confidence. Run the per-residue pLDDT snippet above, then color the model in PyMOL with the
spectrum bcommand. Rotate the model and note which segments, if any, fall into the low-confidence bands. GFP folds into an eleven-stranded beta-barrel, and a healthy prediction should show that barrel clearly in the high-confidence bands.
- Compare against experimental truth when possible. Download a GFP crystal structure from the RCSB Protein Data Bank, load both models in PyMOL or ChimeraX, align them with the viewer's superposition command, and inspect the backbone visually. Most beginners skip this step, and it is the single fastest way to build calibrated intuition about what a confident prediction looks like versus a sloppy one.
If you have followed an AlphaFold tutorial before, you will notice what is missing here: no MSA generation, no template search, no waiting on database servers. That absence is the entire point of ESMFold, and it is what makes the approach practical when you need to fold hundreds or thousands of candidate sequences.
Common Mistakes and Limitations
This is the section that separates a useful ESMFold tutorial from a misleading one. Predicted structures fail in characteristic, predictable ways.
High confidence on sequences that are not real proteins
The most counterintuitive failure is overconfidence. A study evaluating ESMFold, AlphaFold2, and AlphaFold3 on spurious protein sequences, meaning short open reading frames produced by gene prediction errors that theoretically should not fold, found that all three methods assign unexpectedly high pLDDT scores to short spurious sequences [2]. Short sequences lack enough structural context to expose the model's uncertainty. Discrimination between spurious and real proteins improves substantially beyond 100 amino acids [2]. The practical rule for ESMFold beginners is straightforward: do not trust confident predictions for peptides shorter than about 100 residues as evidence that the peptide encodes a folded protein. A high pLDDT on a 40-residue sequence tells you the model can draw a tidy-looking structure, not that biology folded it.
Inter-domain geometry in fusion and multidomain proteins
If your construct is an engineered fusion protein, two domains joined by a flexible linker, be cautious about the relative orientation of the domains. A study of artificial fusion proteins concluded that predicting their structures is not straightforward even with AlphaFold2, because the spatial freedom allowed by the linker and the domain orientations driven by weak noncovalent interactions exceed what current methods resolve reliably [3]. Predicting each domain separately gives you reliable individual domain models but no information about how they sit together. Predicting the full fusion gives you a definite-looking answer for the domain arrangement that may not reflect the real ensemble. Either way, treat inter-domain angles from any single-structure prediction as a hypothesis, and prefer experimental or biophysical validation for designs where the relative domain orientation drives function [3].
Predicted structures are not docking-ready crystal structures
A common next step for beginners is docking small molecules into an ESMFold model. Understand the limits here. Even with AI-predicted structures widely available, experimentally determined structures of protein-drug complexes remain scarce, which is precisely why structure-based drug screening has to lean on computational workarounds such as transferring binding-mode knowledge from crystallized fragments to related compounds [4]. A predicted structure gives you the apo form, without a ligand, with side chains placed by a model rather than by physics. Use ESMFold models for early, coarse virtual screening and hypothesis generation, and expect binding-site geometry, especially side-chain conformations, to need refinement or experimental confirmation before you draw conclusions about ligand interactions [4].
Input hygiene failures
- Non-standard characters. Stop symbols, lowercase sequences that some pipelines interpret differently, B, X, or Z residue codes, and stray digits all cause failures or silent misbehavior. Sanitize input as shown in the worked example.
- Long sequences through the public API. Multi-thousand-residue submissions can time out or be rejected. Split large proteins into domains for the API route, or run locally with a large-memory GPU.
torch.cuda.OutOfMemoryError: CUDA out of memory. This exact message means your GPU lacks memory for the sequence length you submitted. Shorten the sequence, process it in overlapping domain-sized chunks, or move to a larger GPU. There is no software flag that fixes a hard memory limit.HTTPError: 500from the API. The service refused the request. Check that your body is a bare sequence with no header line, check your sequence length, and confirm the endpoint address against the ESM GitHub repository since public endpoints change.
Misreading low confidence as failure
Low pLDDT in a specific region is frequently correct biology, not a model bug. Intrinsically disordered regions have no single stable structure, so any predictor scores them poorly. The right response is to interpret those residues as flexible rather than to keep re-running the prediction hoping for a different answer.
Skipping the database check
Beginners routinely spend compute predicting proteins that already have excellent models in the AlphaFold Database, which hosts around 214 million structures [1], or even experimental structures in the PDB. Search first. Reserve prediction for sequences that are genuinely absent, engineered, or newly designed.
Assuming ESMFold handles complexes
ESMFold predicts single chains. For multi-chain complexes you need AlphaFold-Multimer or AlphaFold 3, accessible through DeepMind's AlphaFold Server or local installations. Feeding a concatenated multi-chain sequence to ESMFold will produce coordinates for a single continuous chain, which is not the same as predicting a complex.
Practical Tips for Better Predictions
These esmfold tutorial tips come from the day-to-day habits of people who run structure prediction at scale.
- Record the model version. Note
esmfold_v1in your lab notebook or methods section. Predictions are version dependent, and reproducibility requires knowing which model produced your coordinates. - Truncate before modeling, not after. If only the first 180 residues of a 400-residue protein are ordered, consider predicting the ordered region separately for downstream tasks that need a clean globular model, while keeping the full-length prediction for context.
- Round-trip your sequences. Keep the exact FASTA files you submitted, with a manifest mapping output PDB filenames to input sequences. Six months from now, that manifest is the difference between a reproducible analysis and a folder of anonymous coordinate files.
- Use pTM for global questions and pLDDT for local ones. If your conclusion is "this protein has a beta-trefoil fold," pTM and the visual fold matter most. If your conclusion is "residue 238 sits in the binding pocket," pLDDT at that residue matters most.
- Sanity-check against homologs. If a close homolog has an experimental structure, align your prediction to it. Agreement within a couple of angstroms for the conserved core is the normal expectation for a well-behaved family.
- Consider ColabFold notebooks if you want ESMFold or AlphaFold2 on Google's hardware without local installation. The ColabFold project maintains notebooks that support both MSA-based and language-model-based prediction, which is useful when you lack a GPU.
Where Predicted Structures Fit in a Research Workflow
Fast single-chain prediction changes what is practical. Structures in the PDB and AlphaFold databases can be mined at the level of the fold itself, comparing shapes rather than sequences, and this approach reveals functional breadth that sequence similarity misses. In one demonstration, fold-to-fold comparison across the PDB and AlphaFold databases identified proteins carrying the beta-trefoil fold across 32 distinct functional classes, spanning cytokines, chitinases, lipases, kinases, and glycosyl hydrolases with varied domain architectures [5]. When you generate your own ESMFold predictions at scale, that same fold-comparison mindset applies: the shape of your predicted model can point toward function even when the sequence has no recognizable relatives.
The workflow that works well in practice is a tiered one. Check the AlphaFold Database and the PDB first. If nothing exists, run ESMFold for speed. If the protein is difficult, short, or part of a complex, escalate to MSA-based AlphaFold2 or AlphaFold 3 through the AlphaFold Server or a local install. Treat every output as a hypothesis with a built-in confidence report, and let the confidence values, not the visual appeal of the cartoon, decide how much weight your conclusions can carry.
Frequently Asked Questions
How fast is ESMFold compared with AlphaFold2?
For a single chain, ESMFold typically finishes in seconds to a few minutes because it skips MSA generation entirely, while MSA-based AlphaFold2 pipelines commonly take substantially longer per protein because of database searches.
Do I need a GPU to run ESMFold?
No, not for the public API method, which runs on remote hardware. For local inference, a CUDA GPU is strongly recommended, since CPU-only prediction is dramatically slower and long sequences may not fit in memory.
Can ESMFold predict protein complexes with multiple chains?
No, ESMFold predicts one polypeptide chain at a time. For complexes, use AlphaFold-Multimer or AlphaFold 3 through DeepMind's AlphaFold Server or a local installation.
What pLDDT score is good enough to trust a model?
Residues above 90 are considered very accurate, 70 to 90 confident for backbone placement, 50 to 70 low confidence, and below 50 usually indicates disorder, so trust depends on which residues your conclusion depends on.
Is ESMFold accurate for short peptides?
Treat short predictions with suspicion, because ESMFold, AlphaFold2, and AlphaFold3 all assign unexpectedly high pLDDT scores to short sequences that should not fold, and reliable discrimination improves for sequences longer than 100 amino acids.
Can I use ESMFold structures for drug docking?
Only for early, coarse screening, because predicted structures lack bound ligands and experimentally determined protein-drug complex structures remain scarce, so binding-site geometry needs refinement or experimental confirmation.
Why is part of my prediction colored red or dark blue?
Those colors mark residues with low pLDDT confidence, which usually means the region is genuinely flexible or intrinsically disordered rather than that the model failed.
Is ESMFold free to use?
Yes, the model weights and code are openly available through Meta's ESM repository, and the public API endpoint is free, though it may rate-limit requests or change address over time.
Sources
- From CASP13 to the Nobel Prize: DeepMind's AlphaFold Journey in Revolutionizing Protein Structure Prediction and Beyond.
- Folding the unfoldable 2: using AlphaFold and ESMFold to explore spurious proteins.
- Fusion of two unrelated protein domains in a chimera protein and its 3D prediction: Justification of the x-ray reference structures as a prediction benchmark.
- Decomposing compounds enables reconstruction of interaction fingerprints for structure-based drug screening.
- Tracing the function expansion for a primordial protein fold in the era of fold-based function prediction: β-trefoil.