logo svg
logo

August 23, 2026

Updated: August 23, 2026

How Does Tor Work? Onion Routing Explained in Simple Terms

Three relays, three layers of encryption, and why no single hop ever sees both ends.

Abdalla Mohamed

Featured Image

How does Tor work? In one sentence: Tor hides who you are by wrapping your traffic in three layers of encryption and bouncing it through three volunteer-run computers, so that no single one of them ever knows both who you are and what you are doing. Each relay peels off one layer, like the layers of an onion, which is where "onion routing" gets its name. The result is that your internet provider cannot see where you go, the sites you visit cannot see who you are, and no single point in the chain can connect the two. This guide explains the whole process step by step, in plain language, with a clear picture of the three-hop circuit that makes it work.

Updated: August 2026. Reflects the current Tor network, v3 onion services, the Tor Browser 15 series (built on Firefox ESR), and the ongoing Arti (Rust) rewrite of Tor's core.

The 30-second answer

When you use the Tor Browser and request a web page, here is what happens, at a glance:

  1. Your Tor client picks three relays from the network: an entry (guard), a middle, and an exit.
  2. It wraps your data in three layers of encryption, one for each relay.
  3. Your traffic travels you → guard → middle → exit → website.
  4. Each relay removes exactly one layer and passes the rest along, learning only the previous and next step.
  5. The website sees the exit relay's IP address, not yours.

Because the job of hiding your identity is split across three independent relays, no single party, not your ISP, not the sites you visit, not any one relay, can see the full picture. That separation is the entire trick. The rest of this guide unpacks each step.

The core idea: onion routing

Most privacy tools route your traffic through one intermediary. A proxy or a VPN sends your data through a single server; that server hides your IP from the destination, but it can see both who you are and where you are going. Tor's founders wanted something stronger, so they designed onion routing: instead of one hop, your traffic passes through several, and instead of one layer of encryption, it is wrapped in several nested layers.

The metaphor is exact. Picture an onion: your message sits at the center, and around it are three layers of encryption. Each relay in the path can peel off only its own layer, revealing just enough information to pass the message to the next relay, never the whole thing. The first relay knows who you are but not your destination; the last relay knows your destination but not who you are; and the middle relay knows neither. No layer, and no relay, sees everything. (For the origin of this design, see our history of who created the dark web.)

The three relays that make Tor work

The three relays that make Tor work

Every Tor connection, called a circuit, is built from three relays, each with a distinct job.

RelayPositionWhat it seesWhat it does
Guard (entry) nodeFirst hopYour real IP address, but not your destinationReceives your encrypted traffic and forwards it inward
Middle nodeSecond hopNeither your identity nor your destinationPasses traffic between guard and exit, keeping them apart
Exit nodeThird hopYour destination, but not your real IPRemoves the final layer and connects to the website

The middle relay is the quiet hero of the design: by sitting between the guard and the exit, it ensures the entry node and exit node never communicate directly and never learn about each other. That is what stops any single relay from linking your identity to your activity.

How a Tor circuit is built, step by step

This is the part a diagram makes obvious, so picture the path as a straight line:

You → [Guard] → [Middle] → [Exit] → Website

Tor does not just fire your data down that line; it builds the circuit carefully and incrementally, negotiating a separate secret key with each relay so that each layer of the onion can only be opened by the right hop. The process, called telescoping, works like this:

  1. Get the map. Your Tor client first downloads a list of available relays (more on where that comes from below). From it, the client chooses a guard, a middle, and an exit.
  2. Handshake with the guard. The client establishes an encrypted connection to the guard relay and negotiates a shared secret key with it using a cryptographic handshake (Tor uses a protocol called ntor, based on Diffie-Hellman key exchange). Now the client and guard share Key 1.
  3. Extend to the middle. Through that encrypted channel, the client asks the guard to extend the circuit to the middle relay, and negotiates a second shared key (Key 2) directly with the middle relay. Crucially, the guard relays these messages but cannot read the new key being set up beyond it.
  4. Extend to the exit. The same way, the client extends one more hop and negotiates a third key (Key 3) with the exit relay. The circuit now has three hops and three independent keys, one per relay.
  5. Send traffic. With the circuit built, the client can send data through all three hops, encrypting it in layers so each relay peels exactly one.

The elegant part is that the client negotiates each key itself, end to end through the growing tunnel, so no relay ever learns the keys shared with the relays beyond it. Each relay knows only its own key and its immediate neighbors.

How the layered encryption works

How the layered encryption works

Once the circuit and its three keys exist, sending data is where the "onion" becomes literal. The client encrypts your message in reverse order, and each relay decrypts one layer on the way out.

StepWhereWhat happens
1Your deviceEncrypt the message with Key 3 (exit), then Key 2 (middle), then Key 1 (guard). Three layers, guard's on the outside.
2Guard nodeRemoves the outermost layer with Key 1, sees the middle relay as the next hop, forwards the rest.
3Middle nodeRemoves the next layer with Key 2, sees the exit relay as the next hop, forwards the rest.
4Exit nodeRemoves the final layer with Key 3, revealing the original request, and sends it to the website.

The reply travels back the same path in reverse, with each relay adding a layer this time, and your client removing all three at the end. At no point does the guard see the actual website, and at no point does the exit see your real IP. That is onion routing in action, and it is the answer to "how does Tor encryption work": not one lock, but three nested locks, each held by a different relay.

What each relay can and cannot see

Because this is the heart of Tor's anonymity, it is worth stating plainly.

QuestionGuardMiddleExit
Sees your real IP?YesNoNo
Sees the website you visit?NoNoYes
Sees the content (if HTTPS)?NoNoNo (encrypted to the site)
Sees the content (if plain HTTP)?NoNoYes
Can link you to your activity?NoNoNo

The last row is the whole point: no single relay can connect your identity to your destination. One important caveat lives in this table, though. The exit node can read your traffic if the site you are visiting does not use HTTPS, which is why using HTTPS matters even on Tor, and why onion services (which never use an exit node) avoid the risk entirely. Our dark web browser guide covers what Tor protects and what it does not in more depth.

How your client finds the relays: directory authorities

For any of this to work, your Tor client needs a trustworthy list of the thousands of relays in the network. It gets one from a small set of special servers called directory authorities, run by trusted members of the Tor Project. These authorities regularly vote on and publish a digitally signed document called the consensus, which lists every public relay along with its address, cryptographic keys, capacity, and exit policy.

Your client downloads this consensus, verifies its signatures, and uses it to choose relays for your circuits. This design matters for security: because the relay list is signed by multiple independent authorities, an attacker cannot easily feed your client a fake list of malicious relays. It is also why simply blocking those relays is how some networks try to block Tor, and why Tor offers bridges to get around that (covered below).

Cells, circuits, and rotation

A few more details explain why Tor behaves the way it does:

How onion services (.onion sites) work

Everything so far describes using Tor to reach the ordinary internet anonymously. Tor can also host websites inside the network, reachable only through Tor at a special .onion address. These are onion services (formerly "hidden services"), and they work differently, with no exit node at all.

At a high level:

  1. The onion service picks several relays to act as its introduction points and advertises them, along with its public key, in a distributed directory.
  2. A visitor's client looks up the service, then picks a random relay to act as a rendezvous point.
  3. The client tells the service (via an introduction point) which rendezvous point to meet at.
  4. Both the client and the service build Tor circuits to that rendezvous point, and communicate through it.

The result is that both ends stay anonymous, the visitor does not learn the server's location and the server does not learn the visitor's, and the traffic never leaves the Tor network, so there is no exit node to eavesdrop. Modern v3 onion addresses are 56 characters long and based on strong ed25519 public-key cryptography, which is why they look like long random strings. Our guide to onion sites explains those addresses, and the dark web search engines and directories like the Hidden Wiki that help people find them.

How Tor gets around censorship: bridges and pluggable transports

Some networks and countries try to block Tor by blocking the public relays listed in the consensus. Tor's answer is bridges: unlisted entry relays that are not in the public directory, so they are much harder to block. To defeat deeper inspection that tries to recognize Tor traffic by its signature, Tor uses pluggable transports such as obfs4 and Snowflake, which disguise Tor traffic to look like ordinary encrypted traffic. This is the same category of problem as other censorship-circumvention techniques like domain fronting, and it is how people in heavily censored regions still reach the open internet.

What Tor does and does not protect

Understanding how Tor works also means understanding its limits. Tor hides your network identity, your IP address and location, from the relays and the sites you visit, and hides your destinations from your ISP (though your ISP can often tell you are using Tor). What it does not do is make you anonymous if you undermine it yourself: logging into a real account, running a compromised device, downloading and opening files outside Tor, or leaking identifying details will deanonymize you no matter how well the circuit performs. Tor also only protects the traffic you route through it, which, with the Tor Browser, is your browsing. It is a powerful network-layer tool, not a magic cloak.

Tor Browser and the future of Tor

For nearly everyone, "using Tor" means using the Tor Browser, a hardened version of Mozilla Firefox (built on the Extended Support Release) that routes everything through Tor and is configured to resist tracking and fingerprinting. Under the hood, the Tor Project is rewriting Tor's core software from C into Rust in a project called Arti, which has reached production use as a client and is progressing toward full feature parity, bringing a more secure and maintainable foundation for the years ahead. The onion routing concept, though, remains exactly what the US Naval Research Laboratory designed in the 1990s.

Common misconceptions about how Tor works

Knowing the mechanics clears up the myths that trip people up:

The bottom line

So, how does Tor work? It splits trust. Rather than routing your traffic through one server that sees everything, Tor sends it through three volunteer relays wrapped in three layers of encryption, so the entry knows who you are but not where you go, the exit knows where you go but not who you are, and the middle keeps them apart. Add a signed directory of relays, fixed-size cells, rotating circuits, persistent guards, and onion services that skip the exit entirely, and you have a system that delivers genuine anonymity by design rather than by promise. It is slower than a direct connection, and it is not foolproof against your own mistakes, but the core idea, no single party sees both ends, is what has made onion routing the backbone of online anonymity for two decades.

Frequently asked questions

How does Tor work to maintain user anonymity?

Tor routes your traffic through three relays wrapped in three layers of encryption. The entry relay sees your IP but not your destination, the exit relay sees your destination but not your IP, and the middle relay keeps the two apart. Because no single relay can link your identity to your activity, you stay anonymous, unless you reveal yourself by logging in or leaking identifying details.

How does onion routing work?

Onion routing wraps your data in nested layers of encryption, one per relay in the path. Each relay peels off exactly one layer to learn only the next hop, never the full route. The layered structure, like the layers of an onion, is what gives the technique its name and ensures no relay sees both where traffic comes from and where it is going.

How does Tor encryption work?

Your client negotiates a separate secret key with each of the three relays, then encrypts your message with all three keys in reverse order (exit, middle, guard). Each relay removes one layer on the way out using its own key. The traffic is encrypted between you and the exit; from the exit to the website it is protected only if the site uses HTTPS.

Is Tor traffic encrypted end to end?

Within the Tor network, yes, your traffic is encrypted across all three hops. But when it leaves the exit node for a regular website, it is only encrypted if that website uses HTTPS. Onion (.onion) services are different: traffic never leaves the Tor network, so it stays encrypted end to end with no exit node involved.

How many relays does Tor use?

A standard Tor circuit uses three relays: a guard (entry), a middle, and an exit. Onion services use more hops overall because both the visitor and the service build circuits to a shared rendezvous point, but the three-relay circuit is the basic building block.

Does Tor hide my activity from my ISP?

Yes, your ISP cannot see which sites you visit through Tor, because your traffic is encrypted and its destination is hidden behind the relays. However, your ISP can usually tell that you are connecting to the Tor network. To hide even that, Tor offers bridges and pluggable transports that disguise the connection.

How do .onion sites work?

An onion service and its visitor each build Tor circuits to a shared rendezvous relay and communicate through it, using introduction points to make the initial connection. Neither side learns the other's location, and traffic never uses an exit node, so it never leaves the Tor network. The site's v3 .onion address is derived from its public key, which is why it is a long string of characters.

background
Let's hack you before real hackers do

Stay secure with DeepStrike penetration testing services. Reach out for a quote or customized technical proposal today

Contact Us