IoU Calculator

Intersection over Union for two axis-aligned boxes.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Enter two boxes by their top-left (x1, y1) and bottom-right (x2, y2) corners and get the Intersection over Union: overlap area divided by combined area. It is the standard metric for object detection.

How to use

1
Step 1
Enter x1, y1, x2, y2 for Box A.
2
Step 2
Enter x1, y1, x2, y2 for Box B.
3
Step 3
Press Calculate.

How it works

IoU = area(A ∩ B) / area(A ∪ B), where the union is area A + area B − intersection. It runs from 0 (no overlap) to 1 (identical boxes). Detection benchmarks often count a prediction as correct when IoU is at least 0.5.

IoU = |A ∩ B| / (|A| + |B| − |A ∩ B|)

Worked example

Two overlapping squares

Input
A = (0, 0, 2, 2); B = (1, 1, 3, 3)
Output
IoU 0.142857; intersection 1; union 7
Walkthrough
Each box has area 4. They overlap in a 1 × 1 square, so the union is 4 + 4 − 1 = 7 and IoU = 1/7. Boxes (0,0,1,1) and (2,2,3,3) give 0.

Limitations

  • Axis-aligned boxes in corner format only; width and height input is not supported.
  • Rotated boxes and segmentation masks are not handled.
  • Coordinates are used as given, so mix of units or pixel and normalised values give wrong answers.

Questions

How do I calculate IoU?
Divide the intersection area by the union area. Enter both boxes to have it calculated.
What IoU threshold is typical?
0.5 is common for detection; stricter benchmarks average over thresholds up to 0.95.
What are the box coordinates?
The top-left corner (x1, y1) and bottom-right corner (x2, y2), in the same units for both boxes.
What IoU do non-overlapping boxes have?
0.

Features

  • Intersection and union
  • Corner coordinates
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • TensorFlow 2.0 Complete Course

    freeCodeCamp.org

    Practical ML stack context next to AI utilities.

    Watch on YouTube
  • Machine Learning for Everybody

    freeCodeCamp.org

    Accessible ML survey for AI calculator and metric tools.

    Watch on YouTube