Skip to content

Polish notation converter

Convert arithmetic between infix, prefix and postfix notation, with a readable evaluation stack.

Inputs

Processed in your browser.

Live preview · not yet confirmed

Use spaces between prefix/postfix tokens. Example: 8 2 - 3 /

Calculation steps · Live preview · not yet confirmed

Result

Calculate to confirm the current inputs.

How to use

Choose the notation you already have, then calculate. Infix puts operators between values; prefix puts them before the two operands; postfix puts them after. All three equivalent expressions are returned, so no separate destination selector is needed.

Read the result

Read the postfix stack from bottom to top. A number is pushed; an operator removes the top two values, applies left operand operator right operand, and pushes the answer. Parentheses in the infix output preserve grouping. Multiplication and division precede addition and subtraction; equal precedence associates left to right.

Example

Infix (8 - 2) / 3 gives prefix / - 8 2 3 and postfix 8 2 - 3 /. Each evaluates to 2. In reverse, either token expression returns ((8 - 2) / 3). Thus infix→prefix, infix→postfix, prefix→infix, prefix→postfix, postfix→infix and postfix→prefix are supported.

Limits and errors

Use decimal points, numbers and + - * / only. A unary sign must be attached to a numeric literal in prefix/postfix, as in -2; infix also accepts - 2. -(2+3), powers, variables, functions, exponent notation and implicit multiplication are unsupported. Maximum 240 characters and 24 nested parentheses; nonzero inputs and intermediate values must have magnitude 10⁻¹²–10¹². Zero division is rejected. Floating-point values are approximate, even when all three evaluations agree.

Frequently asked questions

Why are spaces required?

Without delimiters, 12 3 + could be confused with individual digits. Infix can omit spaces; prefix and postfix must separate every number and operator.

Can I edit or copy the result?

Editing invalidates the confirmed result and disables Copy. Calculate again before copying. Clear leaves the fields empty. The pale example runs immediately; the first focus in a value field clears all example values once.

Sources: Runestone Academy