How to use the Infix to Postfix Converter
- 1. Type the expressionUse letters or numbers with + - * / % ^ and brackets.
- 2. Press ConvertThe tool applies the stack (shunting-yard) method symbol by symbol.
- 3. Study the stepsCompare each row of stack and output with your notebook.
The stack rules
Read the expression left to right:
- Operand (A, 5): write it to the output.
- (: push it onto the stack.
- ): pop to the output until you reach (, then throw both brackets away.
- Operator: pop operators with higher precedence, or equal precedence when the new one is left-associative, then push the new operator.
- At the end, pop everything left.
Precedence is ^ first, then * / %, then + −. The power operator ^ is right-associative, so A ^ B ^ C means A ^ (B ^ C) and becomes A B C ^ ^.
Worked example
For A + B * C - D / E:
- A goes out. + is pushed. B goes out.
- * has higher precedence than +, so it is pushed on top. C goes out.
- − arrives: * and + both have higher or equal precedence, so both are popped, then − is pushed.
- D goes out, / is pushed above −, E goes out, and the end pops / then −.
The result is A B C * + D E / −, and the prefix form is − + A * B C / D E. The stack table above shows the same rows.
With numbers, the tool also works out the value. Try 3 + 4 * 2 / (1 - 5) ^ 2: postfix is 3 4 2 * 1 5 − 2 ^ / +, and the value is 3 + 8 ÷ 16 = 3.5. Computers like postfix because it needs no brackets and can be evaluated with one stack in a single pass.
Frequently asked questions
Does it support negative numbers like -5?
Not as a unary minus. Write (0 - 5) instead. This keeps the rules the same as most textbook questions.
How is prefix worked out?
Reverse the expression, swap the brackets, convert using the same stack idea, then reverse the output.
Can operands have more than one letter?
Yes. Names like total or x1 and numbers like 25 are read as single operands.
Is the converter free?
Yes, free for everyone. The first conversion asks for your name and WhatsApp number once, and then all Uncodemy tools work straight away.