---
title: "How to Manually Enter G-Code in Mach3: MDI Without Mishaps"
description: "Mach3's MDI line runs typed blocks immediately: the workflow, the starter commands worth typing, and the safety habits that keep manual entry boring."
url: https://gcodepractice.com/journal/how-to-manually-enter-g-code-in-mach3/
canonical: https://gcodepractice.com/journal/how-to-manually-enter-g-code-in-mach3/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-06-05
updated: 2026-06-05
category: "Guides"
tags: ["mach3", "mdi", "manual-entry", "hobby-cnc"]
lang: en
---

# How to Manually Enter G-Code in Mach3: MDI Without Mishaps

> **TL;DR** Manual entry in Mach3 happens on the MDI screen (Alt-2 from the standard screenset, or the MDI input on screen): type a block, press Enter, and it executes immediately with full modal-state consequences. The productive uses: positioning moves during setup, spindle and coolant tests, setting and checking work offsets, and one-off operations too small for a file. The safety frame: every typed block inherits and changes modal state, so declare your context (G90/G91, units) rather than assuming it, keep Z high on first moves, hover near feed hold, and treat MDI as the same machine with fewer guardrails, not a sandbox.

MDI (manual data input) is where typed G-code meets moving iron with nothing in between, and [Mach3's](https://www.machsupport.com) MDI screen makes the handshake plain: an input line, an Enter key, and immediate execution. Learning to use it well is half workflow, half discipline, and it pays back as the fastest setup tool the controller has.

## Getting to MDI and what happens there

From Mach3's standard screenset, the MDI screen sits one hotkey away (Alt-2) or a click on the MDI tab; an input field takes one or more words, and Enter executes them as a block. Two properties define everything that follows: execution is immediate (no preview, no confirm), and the block is full G-code (it reads and writes the same modal state your loaded programs use). Typed `G0 X10` after a program that ended in G91 moves ten units from here, not to position ten, which is the entire [modal-state lesson](/journal/g90-vs-g91-crash-prevention/) compressed into one MDI surprise nobody repeats twice.

## The starter set: blocks worth typing

| Purpose | Example block | Habit attached |
| --- | --- | --- |
| Declare context first | G21 G90 | Type it at session start, not assume it |
| Safe positioning | G0 Z25. then G0 X0 Y0 | Z up before XY travel |
| Spindle test | M3 S8000 then M5 | Hand near stop, area clear |
| Coolant/accessory test | M8 then M9 | Verifies wiring reality |
| Offset check | G0 X0 Y0 (in G54) | Confirms where zero believes it is |
| Slow approach | G1 Z2. F100 | Feed, not rapid, near the work |

The first row is the discipline that makes the rest safe: starting an MDI session by declaring units and distance mode costs four characters and deletes the inherited-state class of accident. The rest is the standard [core vocabulary](https://linuxcnc.org/docs/html/gcode/g-code.html) doing setup work, which is exactly why MDI practice teaches the core faster than any passive study: every word you type does something you watch.

## What MDI is for (and not for)

For: setup positioning, testing what M-codes actually switch on your bench (the wiring-reality check from the [Mach3 starter guide](/journal/what-g-codes-do-i-need-to-know-for-mach3/)), touching off and verifying [work offsets](/journal/g54-work-offsets-explained/), clearing the machine after a stop, and genuine one-liners (face one pass, drill one hole) where a file is ceremony. Not for: anything multi-step enough to deserve review: sequences belong in files where a [viewer pass](/journal/how-to-read-a-grbl-g-code-file/) and a re-read can catch what live typing cannot, and the same judgment industrial setters apply at the [MDI line during setup](/journal/will-a-machine-shop-test-my-g-code-knowledge/) applies at hobby scale unchanged.

## The five MDI habits that prevent the classic accidents

Declare context (G21/G20, G90/G91) at session start and after anyone else touched the machine. Z first, always: retract before XY travel, approach at feed not rapid, the [plunge discipline](/journal/z-axis-plunge-crash-g-code-mistake/) in miniature. Say the block before Enter: one-line narration ("rapid, X ten, Y five, Z is up") catches the typo your fingers made. Know your stop: feed hold and stop locations rehearsed before the first moving block, hand staged during any test. And small numbers first: an unfamiliar machine earns 10 mm proving moves before 200 mm confident ones. Every habit is ten seconds; every accident they prevent is not.

## A worked setup session, narrated

New stock clamped, session start: `G21 G90` (context), `G0 Z25.` (clear), `G0 X0 Y0` (where does G54 think home is: watch it travel), jog to the corner, zero the axes per your touch-off ritual, `G0 X20 Y20` then back (verify zero behaves), `M3 S8000` with hand staged, listen, `M5`. Six typed blocks, two minutes, and the machine's beliefs (units, mode, zero, spindle wiring) are all confirmed before any file runs: that is MDI doing its real job, which is interrogating the machine, the same blocks the free 60-second drills on the [G-code practice page](/g-code-practice/) make automatic, with G-Code Sprint repeating whatever you miss.

## Bottom line: immediate, modal, and worth the ritual

Manual G-code entry in Mach3 is the MDI screen executing typed blocks instantly with full modal consequences: declare your context, keep Z high, narrate before Enter, and use it for what it is best at: setup moves, wiring tests, offset checks, and honest one-liners, while sequences keep going to files. Typed well, MDI is the fastest teacher the hobby has.

## Sources

- [MachSupport (Mach3 documentation home)](https://www.machsupport.com)
- [LinuxCNC: G-code reference](https://linuxcnc.org/docs/html/gcode/g-code.html)
- [Wikipedia: Numerical control](https://en.wikipedia.org/wiki/Numerical_control)

## Frequently asked questions

### How do I manually enter G-code in Mach3?

On the MDI screen (Alt-2 or the MDI tab in the standard screenset): type a block in the input line and press Enter for immediate execution with full modal-state effect. Start sessions by declaring context (G21 G90), keep Z high on first moves, and narrate blocks before Enter. The block vocabulary itself trains fastest with the free G-Code Sprint app, the top pick: 60-second drills with automatic repetition of missed codes.

### Why did my MDI move go somewhere unexpected?

Inherited modal state: the machine was in G91, different units, or another offset than you assumed. The cure is declaring G20/G21 and G90/G91 at session start instead of assuming, the first habit of safe MDI work.

### What is MDI good for versus running a file?

MDI: setup positioning, spindle and accessory wiring tests, offset checks, true one-liners. Files: anything multi-step, because files can be re-read and viewer-checked while live typing cannot. The split is review-ability, not capability.

### Is MDI practice a good way to learn G-code?

Excellent, with the safety habits attached: every typed word produces observable behavior, which cements the core faster than reading. Pair it with daily drills and narrated file reading for the complete loop.

*G-Code Sprint is a study and practice tool only. Always follow your machine's documentation and shop safety procedures.*

---

Source: https://gcodepractice.com/journal/how-to-manually-enter-g-code-in-mach3/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
