system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How does connecting to a hidden service over tor work?

I've heard it explained a million times but it never clicked. Perhaps it's the cryptography part im struggling with. It's pretty easy for me to get overwhelmed by the technical terms.

To be clear, im talking about how a client running the tor browser manages to anonymously connect to a .onion webserver.
gpt
Okay lets just say brackets mean you encrypt something. Only the correct receiver has the key to unlock it.

Regular encryption would then be 

"adress (message)"

You encrypt what you're saying, but you can't encrypt who you talk to (because the ISP needs to know to route the message correctly)

Tor simply routes through multiple relay points. So the message you send looks like

"adress1(adress2(adress3(message)))"

From the outside it looks like you send an encrypted message to adress 1. But that isn't the final destination. Relay server 1 opens the first layer of encryption and finds an adress, so it sends the remaining encrypted message to adress 2, who has the key to open the second layer of encryption. And so on.

In the end noone in the chain knows who the final destination is. So even if one of the servers gets hacked/raided they only see a bunch of encrypted messages getting forwarded, without any idea if the adress is just another relay or the actual receiver. (And also no information who the original sender is, they can only see one step in the chain)