As long as the teleport doesn't require you to move, so the ones you'd generally think of will work, but things like teleport circle or transport via plants would not.
You’re not being bear-hugged or pinned to the ground in a grapple - you’re just being stopped from moving and nothing more. You can still attack, cast spells, hurl profanities etc, etc.
And anything that takes either you or the grappler out of reach (such as teleport) ends the grapple.
Always pay close attention to what the rules say and what they don't say. Grappled says your movement speed is reduced to 0. That's it. It does not inhibit your ability to cast spells or use object that let you cast spells like magic rings, scrolls, etc. As long as the spell or ability you're using doesn't require you to move(such as to step through a portal), you can do it. So Misty Step, Misty Escape, Fey Step, Shadow Step, Teleport, Dimension Door all work. Arcane Gate, Teleportation Circle, Transport Via Plants, not so much.
If you are grappled can you teleport out of it?
As long as the teleport doesn't require you to move, so the ones you'd generally think of will work, but things like teleport circle or transport via plants would not.
Yes - it’s important not to mistake Grappled for Incapacitated
You’re not being bear-hugged or pinned to the ground in a grapple - you’re just being stopped from moving and nothing more. You can still attack, cast spells, hurl profanities etc, etc.
And anything that takes either you or the grappler out of reach (such as teleport) ends the grapple.
Always pay close attention to what the rules say and what they don't say. Grappled says your movement speed is reduced to 0. That's it. It does not inhibit your ability to cast spells or use object that let you cast spells like magic rings, scrolls, etc. As long as the spell or ability you're using doesn't require you to move(such as to step through a portal), you can do it. So Misty Step, Misty Escape, Fey Step, Shadow Step, Teleport, Dimension Door all work. Arcane Gate, Teleportation Circle, Transport Via Plants, not so much.
"Not all those who wander are lost"