Minecraft Nether Portal Calculator
Four short steps: say where you are, type your position, build where the calculator points, and check that the two portals link. Java Edition, 1.16.2 and up.
Not an official Minecraft product. Not approved by or associated with Mojang or Microsoft. The rules on this page are Java Edition's, from the game's own portal code, and a future version can change them. The portal picture is Mojang's, the Minecraft Wiki's animated render.
How the maths works
The Nether is a small copy of the Overworld. Every block you walk down there is eight blocks up top. Walk 100 blocks in the Nether, pop back up, and you have moved 800 blocks at home. That is why people dig a tunnel through the Nether between their bases: you travel eight times further for the same walk.
So to find your spot in the Nether, divide your X and Z by 8. To go the other way, multiply them by 8. Your height, Y, is never divided. It stays exactly the same number.
One catch. The game only deals in whole blocks, so it always rounds down, and that includes minus numbers: -100 divided by 8 is -12.5, and the game calls that -13, not -12. The calculator rounds the same way the game does, so what you see is where you land.
Why portals link to the wrong place
Walking into a portal does not always build you a new one. The game works out where you ought to come out, has a look around that spot for a portal that is already there, and only builds a fresh one if it finds nothing.
How far it looks is the bit that catches people out: 16 blocks each way in the Nether, 128 each way in the Overworld. Everything shrinks by eight on the way in, so two portals about a hundred blocks apart at home land within 16 blocks of each other in the Nether. That is close enough for the second one to send you to the first one's Nether portal, which is why two doors at home so often open into the same room.
The cure is room. Keep your Nether portals more than 32 blocks apart and no pair can steal another pair's traffic. Step 4 above checks both trips for any two portals you have already built.