Free · G-code made in your browser · no signup

Z Offset Calibration: Test Squares at Different Heights

Download a G-code file of numbered solid squares, each printed at a slightly different first-layer height from the nozzle to the bed. Print it, find the square that is smooth and fused with no gaps, and enter its number to get the Marlin or Klipper commands that move your Z offset by that amount.

Loading the Z offset generator...

How to set your Z offset with this test

  1. 1

    Enter your printer

    Pick Marlin, Klipper or RepRapFirmware, your bed size and temperatures, and the first layer height you print with. Choose a grid or a single row.

  2. 2

    Print the squares

    Download the file, home and heat the printer as usual and print it. Watch the first layer, since the lowest squares are close to the bed.

  3. 3

    Pick one square

    Compare the squares in good light. The right one is smooth and flat, fused into a single sheet, with no gaps and no ridges between lines.

  4. 4

    Apply the change

    Enter its number to get the commands, and move the nozzle by that amount. Print the test once more to confirm.

How to tell the squares apart

All squares get the same amount of plastic per millimetre. Only the nozzle height changes, so the difference you see is how much the plastic is squashed.

Much too closeThe surface is rough, the lines have ridges, and the plastic is pushed out sideways at the edges. The extruder may click or grind on the filament.
A little closeThe square is smooth, but a raised edge shows around it and it is hard to peel off. Choose the square one step higher.
Right heightThe lines are fused into a flat, even surface with no gaps. A fingernail runs across it without catching on the lines.
A little highThe lines are rounder and show faint grooves between them. They stick, but a thin gap may show in the light.
Much too highThe lines are round and apart, with clear gaps, and they may lift or drag on the bed.
Square numbersSquare 1 is at the front left and the numbers rise to the right and then toward the back. A key with the offset for each square is in the file comments.

What the Z offset is

The Z offset is the distance between the nozzle and the bed when the printer thinks it is at zero height. If the printer has a probe, it is the gap between where the probe triggers and where the nozzle tip sits; if it uses an end stop, it is the position of that end stop. Either way it decides how far the nozzle is from the bed for the first layer, and a few hundredths of a millimetre can be the difference between a print that sticks and one that does not.

A first layer that is too high does not stick well and may peel off in the middle of a print. One that is too low squashes the plastic into the bed, leaves ridges and a flared bottom edge, and can block the nozzle so that the extruder clicks. A good first layer is slightly flattened and joined into one sheet.

A single flat test shows only one height, so you have to guess which way to move. This test prints several heights side by side in one go, so you can see the whole range and choose the right square.

Reading the squares and picking one

Each square is printed at your first layer height plus its own offset, for example from minus 0.15 to plus 0.15 mm in steps of 0.05 mm. A negative offset puts the nozzle closer to the bed, a positive one farther away. The extrusion per millimetre is the same in every square, so a square printed closer is squashed more and a square printed higher is squashed less. Square numbers are printed above the squares as small digits, and the preview on this page shows which number is which.

Look at the test in good light, and run a finger across the surface. Choose the square that is flat and fused, with no gaps and no ridges. Type its number in the box on this page and the tool shows the exact change in millimetres, with the commands for your firmware. If the right square is at the end of the row, run the test again with a wider range in that direction.

Heat the nozzle and the bed to printing temperature and give them a few minutes before you print: a hot printer is not the same height as a cold one. If you use a bed mesh, tick the mesh option so the printer probes the bed first.

Applying the result safely

In Marlin, M851 Z holds the probe offset and M290 Z adjusts the live babystep. After you change it, M500 saves the setting to the EEPROM. In Klipper, SET_GCODE_OFFSET Z_ADJUST= moves the nozzle straight away, and Z_OFFSET_APPLY_PROBE (or Z_OFFSET_APPLY_ENDSTOP for a printer with an end stop) copies that into the probe z_offset or position_endstop, followed by SAVE_CONFIG. Your slicer may also have a Z offset or first-layer height setting that does the same job without touching the printer.

Change the offset by small amounts and never go below the bed: the file you download never uses a Z of 0.02 mm or less. If the lowest square would have been that low, it is raised to a safe height and the tool warns you. If your first layer height is very small, raise it for this test.

The tool only produces a G-code file. Check the start G-code and temperatures for your printer, and watch the first layer, since a wrong offset can scrape the bed. Stop the print if the nozzle drags.

Prints sticking? Design the next one

With the first layer set, turn a picture or a description into a model you can print.

More calibration tools

Z offset calibration FAQ

The distance between the nozzle and the bed when the printer reads zero height. It sets the gap for the first layer, which decides how well the print sticks.
Gaps between first-layer lines and a print that peels off mean it is too high. A rough, ridged surface, a flared bottom or a clicking extruder mean it is too low.
A first layer test prints one height and you adjust and reprint. This one prints several heights in one file, so you see the whole range and pick a square, then reprint once to check.
In this test a positive offset puts the nozzle farther from the bed and a negative one closer. The apply box shows the signed change for your firmware, so you do not need to work out the sign.
Yes. Tick the mesh option so the printer probes the bed first. Each square is then the offset on top of the mesh height. Keep the squares small and the bed warm so the result is comparable.
Run the test again with a wider range in that direction, for example from 0 to plus 0.3 mm, then pick again.
A Z at or below 0.02 mm is never written. If an offset would reach that, the square is raised to 0.03 mm and the tool warns you. Use a taller first layer for this test.
No. The G-code is built in your browser and downloaded as a file. You copy it to your printer yourself.

The G-code is made in your browser and downloaded as a file. Nothing is sent to your printer. Check the start G-code and temperatures for your printer before printing, and watch the first layer.