Infix to Postfix & Prefix Converter (Shunting-Yard)
Convert an infix expression to postfix (reverse Polish) and prefix notation with the shunting-yard algorithm, showing the stack at each step. Also converts postfix or…
Convert an infix expression to postfix (reverse Polish) and prefix notation with the shunting-yard algorithm, showing the stack at each step. Also converts postfix or prefix back to infix and evaluates numeric expressions.
Results
About This Calculator
Use letters or numbers with + − * / % ^ and brackets. ^ is right-associative (2^3^2 = 2^9); the other operators are left-associative.
In postfix the operator comes after its two operands (A B +), and in prefix before them (+ A B). Separate tokens with spaces when converting from postfix or prefix.
Example
Example: A + B * (C - D) / E becomes A B C D - * E / + in postfix and + A / * B - C D E in prefix.
Assumptions
Binary operators only (no unary minus). Values are shown only when every operand is a number.
Frequently Asked Questions
Why use postfix notation?
It needs no brackets and is easy for a computer to evaluate with one stack. RPN calculators work this way.
What is the shunting-yard algorithm?
Dijkstra's method for converting infix to postfix: operands go straight to the output, and operators wait on a stack until a lower-precedence operator or a closing bracket arrives.
Related Calculators
About the Author

Professional SEO, Digital Marketer Specialist
I am a Certified Google Ads Expert And Professional SEO, Digital Marketing Specialist
View full profile