Postfix to Infix Converter with Built-in Dynamic Tutorial

Postfix to Infix Converter Sign

This calculator will convert a postfix expression (Reverse Polish Notation) to an infix expression and show the step-by-step process used to arrive at the result using stack.

If you're not sure what is meant by the terms infix, postfix, or stack, please visit the Learn section of the Infix to Postfix Converter page.

If you would like to convert a prefix expression back to an infix expression, please visit the Prefix to Infix Converter. Or, if you would like to convert a postfix expression (4 3 *) to prefix (* 4 3), please visit the Postfix to Prefix Converter.

Read more ...

Also on this page:

Postfix to Infix Converter

Convert postfix to infix and see the step-by-step process for completing the conversion.

Learn More

Selected Data Record:

A Data Record is a set of calculator entries that are stored in your web browser's Local Storage. If a Data Record is currently selected in the "Data" tab, this line will list the name you gave to that data record. If no data record is selected, or you have no entries stored for this calculator, the line will display "None".

DataData recordData recordSelected data record: None
Example notations:

Example postfix expressions:

To see an example of how the Postfix to Infix Converter works, and what types of expressions the calculator is set up to handle, select a postfix expression from the drop-down menu. To clear the expression field to enter your own postfix expression, select "Example Problems" or click the "Reset" button.

Postfix expression:

Postfix expression:

Enter a postfix expression that fits within the following guidelines:

  • Include a single space between numbers or operators.
  • Numbers, single letters, and operators only (no variables or function names).
  • Contains only numbers, decimal points, letters, and these valid characters: ^ * / + - .
  • Numbers with a leading decimal point must be preceded by a zero (enter .5 as 0.5).
#
Result:

Infix:

This line will display the result of the postfix to infix conversion.

If you would like to save the current entries to the secure online database, tap or click on the Data tab, select "New Data Record", give the data record a name, then tap or click the Save button. To save changes to previously saved entries, simply tap the Save button. Please select and "Clear" any data records you no longer need.

Related Calculators

infix to postfix converterpostfix to prefix converterpostfix evaluator

Help and Tools

Learn

How to convert postfix notation into infix notation.

How to Convert Postfix Notation to Infix Notation Using Stack

Working from left to right, scan each character of the postfix expression, and take one of the following two actions.

If the character is an operand, push it to the stack.

If the character is an operator, pop the top value from the stack for its right operand and pop the next top value from the stack for its left operand. Finally, insert the operator between its operands, place the infix string within a set of parenthesis, and then push the infix string back to the stack.

Repeat the above scanning and subsequent actions until all postfix characters have been handled. If the postfix expression was valid, you should be left with a single element in the stack, which is the infix equivalent of the postfix expression.

Posfix to Infix Conversion Examples

The following are two examples showing how to apply the conversion process detailed in the previous section.

Example #1: 5 6 2 ^ 2 - *

5 6 2 ^ 2 - *

The first character scanned is "5", which is an operand, so push it to the stack.

5
  
StackInfix String

5 6 2 ^ 2 - *

The next character scanned is "6", which is an operand, so push it to the stack.

6
5
  
StackInfix String

5 6 2 ^ 2 - *

The next character scanned is "2", which is an operand, so push it to the stack.

2
6
5
  
StackInfix String

5 6 2 ^ 2 - *

The next character scanned is "^", which is an operator, so pop its two operands from the stack. Pop 2 from the stack for the right operand and then pop 6 from the stack for the left operand. Next, insert the "^" between its two operands to form the infix string 6 ^ 2, and then place that string inside a set of parenthesis.

5
 (6 ^ 2) 
StackInfix String

Next, push the infix string (6 ^ 2) to the stack.

(6 ^ 2)
5
  
StackInfix String

5 6 2 ^ 2 - *

The next character scanned is "2", which is an operand, so push it to the stack.

2
(6 ^ 2)
5
  
StackInfix String

5 6 2 ^ 2 - *

The next character scanned is "-", which is an operator, so pop its two operands from the stack. Pop 2 from the stack for the right operand and then pop (6 ^ 2) from the stack for the left operand. Next, insert the "-" between its two operands to form the infix string (6 ^ 2) - 2, and then place that string inside a set of parenthesis.

5
 ((6 ^ 2) - 2) 
StackInfix String

Next, push the infix string ((6 ^ 2) - 2) to the stack.

((6 ^ 2) - 2)
5
  
StackInfix String

5 6 2 ^ 2 - *

The next character scanned is "*", which is an operator, so pop its two operands from the stack. Pop ((6 ^ 2) - 2) from the stack for the right operand and then pop 5 from the stack for the left operand. Next, insert the "*" between its two operands to form the infix string 5 * ((6 ^ 2) - 2), and then place that string inside a set of parenthesis.

 
 (5 * ((6 ^ 2) - 2)) 
StackInfix String

Next, push the infix string (5 * ((6 ^ 2) - 2)) to the stack.

(5 * ((6 ^ 2) - 2))
  
StackInfix String

Since we are done scanning characters, the remaining element in the stack ((5 * ((6 ^ 2) - 2))) becomes the result of the postfix to infix conversion.

Postfix notation: 5 6 2 ^ 2 - *
Infix equivalent: (5 * ((6 ^ 2) - 2))
Example #2: 7 2 ^ 25 10 5 / + * 13 -

7 2 ^ 25 10 5 / + * 13 -

The first character scanned is "7", which is an operand, so push it to the stack.

7
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "2", which is an operand, so push it to the stack.

2
7
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "^", which is an operator, so pop its two operands from the stack. Pop 2 from the stack for the right operand and then pop 7 from the stack for the left operand. Next, insert the "^" between its two operands to form the infix string 7 ^ 2, and then place that string inside a set of parenthesis.

 
 (7 ^ 2) 
StackInfix String

Next, push the infix string (7 ^ 2) to the stack.

(7 ^ 2)
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "25", which is an operand, so push it to the stack.

25
(7 ^ 2)
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "10", which is an operand, so push it to the stack.

10
25
(7 ^ 2)
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "5", which is an operand, so push it to the stack.

5
10
25
(7 ^ 2)
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "/", which is an operator, so pop its two operands from the stack. Pop 5 from the stack for the right operand and then pop 10 from the stack for the left operand. Next, insert the "/" between its two operands to form the infix string 10 / 5, and then place that string inside a set of parenthesis.

25
(7 ^ 2)
 (10 / 5) 
StackInfix String

Next, push the infix string (10 / 5) to the stack.

(10 / 5)
25
(7 ^ 2)
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "+", which is an operator, so pop its two operands from the stack. Pop (10 / 5) from the stack for the right operand and then pop 25 from the stack for the left operand. Next, insert the "+" between its two operands to form the infix string 25 + (10 / 5), and then place that string inside a set of parenthesis.

(7 ^ 2)
 (25 + (10 / 5)) 
StackInfix String

Next, push the infix string (25 + (10 / 5)) to the stack.

(25 + (10 / 5))
(7 ^ 2)
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "*", which is an operator, so pop its two operands from the stack. Pop (25 + (10 / 5)) from the stack for the right operand and then pop (7 ^ 2) from the stack for the left operand. Next, insert the "*" between its two operands to form the infix string (7 ^ 2) * (25 + (10 / 5)), and then place that string inside a set of parenthesis.

 
 ((7 ^ 2) * (25 + (10 / 5))) 
StackInfix String

Next, push the infix string ((7 ^ 2) * (25 + (10 / 5))) to the stack.

((7 ^ 2) * (25 + (10 / 5)))
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "13", which is an operand, so push it to the stack.

13
((7 ^ 2) * (25 + (10 / 5)))
  
StackInfix String

7 2 ^ 25 10 5 / + * 13 -

The next character scanned is "-", which is an operator, so pop its two operands from the stack. Pop 13 from the stack for the right operand and then pop ((7 ^ 2) * (25 + (10 / 5))) from the stack for the left operand. Next, insert the "-" between its two operands to form the infix string ((7 ^ 2) * (25 + (10 / 5))) - 13, and then place that string inside a set of parenthesis.

 
 (((7 ^ 2) * (25 + (10 / 5))) - 13) 
StackInfix String

Next, push the infix string (((7 ^ 2) * (25 + (10 / 5))) - 13) to the stack.

(((7 ^ 2) * (25 + (10 / 5))) - 13)
  
StackInfix String

Since we are done scanning characters, the remaining element in the stack ((((7 ^ 2) * (25 + (10 / 5))) - 13)) becomes the result of the postfix to infix conversion.

Postfix notation: 7 2 ^ 25 10 5 / + * 13 -
Infix equivalent: (((7 ^ 2) * (25 + (10 / 5))) - 13)

Adjust Calculator Width:

Move the slider to left and right to adjust the calculator width. Note that the Help and Tools panel will be hidden when the calculator is too wide to fit both on the screen. Moving the slider to the left will bring the instructions and tools panel back into view.

Also note that some calculators will reformat to accommodate the screen size as you make the calculator wider or narrower. If the calculator is narrow, columns of entry rows will be converted to a vertical entry form, whereas a wider calculator will display columns of entry rows, and the entry fields will be smaller in size ... since they will not need to be "thumb friendly".

Show/Hide Popup Keypads:

Select Show or Hide to show or hide the popup keypad icons located next to numeric entry fields. These are generally only needed for mobile devices that don't have decimal points in their numeric keypads. So if you are on a desktop, you may find the calculator to be more user-friendly and less cluttered without them.

Stick/Unstick Tools:

Select Stick or Unstick to stick or unstick the help and tools panel. Selecting "Stick" will keep the panel in view while scrolling the calculator vertically. If you find that annoying, select "Unstick" to keep the panel in a stationary position.

If the tools panel becomes "Unstuck" on its own, try clicking "Unstick" and then "Stick" to re-stick the panel.