Home › Calculators › G-Code Viewer

G-Code Viewer

Open a .gcode, .nc or .ngc file, or paste G-code, and see the toolpath in 2D or 3D. Step through layers, replay the moves, tell rapids from cutting or extrusion, and get the bounding box, distances, filament use and an estimated run time. Your file never leaves your browser.

Last updated:

or drop a file anywhere on the viewer
Edit or paste G-code
Edits preview automatically for small programs.
Advertisement
Advertisement

How to use the G-Code Viewer

  1. Open a G-code file with the button, drop it on the viewer, or paste code into the Edit or paste G-code box. A 3D print sample loads automatically.
  2. Switch views between Top (2D), 3D and Front. Drag to rotate in 3D or to pan in 2D, and use the mouse wheel, pinch or the +/− buttons to zoom.
  3. Move the Layer slider to inspect each layer or cutting depth, and tick Current layer only to isolate it.
  4. Press Play or drag the Moves shown slider to watch the toolpath build up move by move.
  5. Read the stats for size, ranges, distances, filament and estimated time, then copy the summary or download a PNG of the view.

Reading a G-code program

G-code is a list of plain-text commands, one per line. Each line holds words made of a letter and a number: G1 X20 Y10 F1200 means “move in a straight line to X 20, Y 10 at 1,200 mm per minute”. Comments start with a semicolon or sit inside parentheses. Motion commands are modal, so a following line with only X30 repeats the last G1.

CodeMeaningHow the viewer shows it
G0Rapid move (no cutting)Dashed red line; uses the rapid speed for CNC time
G1Linear move at feed rate FSolid line (cut or extrusion), travel if it does not extrude in a print
G2 / G3Clockwise / counterclockwise arc, center I J or radius RSmooth arc split into short segments, helical if Z changes
G4 P…Dwell (pause)Added to the estimated time
G20 / G21Inch / millimeter unitsConverted internally; display units follow the file
G90 / G91Absolute / relative coordinatesApplied to X, Y, Z (and E)
M82 / M83Absolute / relative extrusionUsed to work out filament use
G92Set current position (often G92 E0)Resets the axis without moving
G28Home axesRapid move to 0 on the homed axes
F, S, TFeed rate, spindle speed or temperature, tool numberFeed rate used for time; tools listed in the stats

What to check before you run a file

  • Bounding box vs. machine travel: compare the X, Y and Z ranges with your bed or table size, and confirm the program starts where you expect relative to your work zero.
  • Rapids through the part: in CNC programs, dashed rapid lines should stay above the stock. A rapid that dips below the top surface is a crash risk.
  • Cut depths: each layer of a CNC program is a distinct Z depth. Step through them to confirm the final depth and the number of passes.
  • First layer: for prints, isolate layer 1 to check that the skirt, brim and first perimeter sit inside the bed.
  • Units: a file written in inches (G20) but run in millimeters would be 25.4 times too small; the stats show which unit system the file uses.

Frequently asked questions

Is my G-code uploaded anywhere?

No. The file is read and drawn entirely in your browser with JavaScript, so it never leaves your computer. That also means very large files are limited only by your device's memory.

Which G-code commands are supported?

Linear moves G0 and G1, arcs G2 and G3 in the XY plane with I/J centers or an R radius, dwell G4, inch and millimeter units G20/G21, absolute and relative positioning G90/G91, extruder modes M82/M83, position resets G92 and homing G28. Codes such as canned drilling cycles or cutter compensation are listed as not simulated rather than guessed.

How is the time estimate calculated?

Each move's length is divided by its feed rate (F, in units per minute), and dwells and extruder-only retract moves are added. CNC rapids use the rapid speed you enter. Real machines accelerate and slow down at corners, so actual run times are usually somewhat longer, especially for prints with many short segments.

How does the viewer tell a 3D print from a CNC program?

If any move extrudes filament (E increases while the head moves), the file is treated as a print: extruding moves are drawn solid and non-extruding moves are shown as travel, and layers follow the Z height of the extrusion. Otherwise G1/G2/G3 moves are cuts, G0 moves are rapids, and layers are the distinct cutting depths.

How is filament weight estimated?

The net length of filament pushed by the extruder is converted to volume using the filament diameter you enter (1.75 mm by default) and multiplied by 1.24 g/cm³, a typical density for PLA. Other materials differ: PETG is about 1.27 g/cm³ and ABS about 1.04 g/cm³.

Why do some arcs look wrong?

Arc centers given with I and J are relative to the start point by default (G91.1 mode), which is what almost all CAM software outputs. Arcs in the XZ or YZ plane (G18/G19) are drawn as straight lines and flagged in the notes.

Which file types can I open?

Any plain-text G-code file, including .gcode, .gco, .g, .nc, .ngc, .tap and .cnc. Binary formats such as compressed .bgcode files are not supported; export plain G-code from your slicer instead.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

3D Printing Cost CalculatorCost and selling price of a 3D print: filament, power, machine wear, failures and labor.3D Printer Filament Length CalculatorFilament weight to length and back for PLA, PETG, ABS and more, plus spool remaining.Speeds and Feeds CalculatorSpindle RPM and feed rate (mm/min, in/min) from tool size, flutes, surface speed and chip load.3D Graphing CalculatorPlot z = f(x, y) surfaces and 3D parametric curves; rotate, zoom, add contours, save PNG.Gear Ratio CalculatorGear ratio, output rpm and torque for multi-stage gear trains, plus vehicle speed at rpm.BTU CalculatorEstimate air conditioner BTU, tons and heating BTU for a room from its size and conditions.Pipe Flow Rate CalculatorFlow rate from pipe diameter and velocity (GPM, L/s, m³/h), velocity from flow, or pipe size.Rebar CalculatorRebar for a slab grid: bars each way, total length, weight by bar size and stock bars.Beam Deflection CalculatorMax deflection, moment and shear for simply supported, cantilever or fixed beams.Sheet Metal Bend Allowance CalculatorBend allowance, bend deduction and flat blank length from thickness, radius, angle, K-factor.Bolt Torque CalculatorTightening torque for metric and UNC/UNF bolts from grade, lubrication and target preload.Duct Size CalculatorRound duct diameter and equivalent rectangular duct sizes from CFM and friction or velocity.Room Heat Loss CalculatorRoom heat loss in BTU/h and watts from walls, windows, ceiling, floor and air leakage.Moment of Inertia CalculatorMass moment of inertia of common shapes and area moment of beam sections, incl. I-beams.Pulley Belt and Speed CalculatorDriven RPM, belt length, belt speed and ratio from pulley diameters and center distance.Steel Weight CalculatorWeight of steel plate, bar, pipe, tube and angle in kg and lb from dimensions and material.Tap Drill Size CalculatorTap drill size for metric, UNC and UNF threads at any thread %, with a full drill chart.Pipe Volume CalculatorWater volume in a pipe by NPS/schedule or inner diameter: gallons, liters, weight, fill time.Air Changes per Hour CalculatorCalculate ACH from CFM and room size, CFM for a target ACH, ACH50 or ASHRAE ventilation.Aviation Fuel CalculatorFlight fuel required with taxi, reserves and alternate, in gallons, liters and pounds.Bearing CalculatorInitial and final bearing, compass direction and great-circle distance between two coordinates.Belt Length CalculatorBelt length from two pulley diameters and center distance, or center distance from a belt.Bolt Circle CalculatorX/Y coordinates for every hole on a bolt circle, with a drawing and CSV export.Drone Flight Time CalculatorEstimate drone flight time from battery mAh, voltage, discharge, weight and amp draw.E6B Flight ComputerOnline E6B: wind correction, heading, ground speed, time-speed-distance, fuel and conversions.Hydraulic Cylinder CalculatorPush and pull force, extend and retract speed, cycle time and oil volume from bore, rod and pressure.ISO Fits and Tolerances CalculatorHole and shaft limits, clearance or interference and fit type for ISO 286 fits like H7/g6.Map Distance CalculatorClick points on a map to measure a path in km, miles or nautical miles, with GPX export.Pipe Schedule ChartOD, wall thickness, ID, weight per foot and volume for any NPS and pipe schedule.Pump Power CalculatorHydraulic, shaft and motor power in kW and HP from flow, head, specific gravity and efficiency.Section Modulus CalculatorSection modulus, moment of inertia, centroid and radius of gyration for beams and shapes.Shear and Moment Diagram CalculatorDraw shear force and bending moment diagrams with reactions and max values for any beam.Spur Gear CalculatorPitch, outside and root diameters, center distance and tooth sizes from module or DP.Stress and Strain CalculatorStress, strain and Young's modulus from force, area and length change, with material checks.Tension CalculatorRope tension for a hanging mass on one or two angled ropes, a pulled object or a pulley.Screw Thread CalculatorUNC, UNF and metric thread dimensions: major, pitch and minor diameters, tap drill and limits.Aircraft Weight and Balance CalculatorAircraft weight and balance: total weight, moment and CG, plotted against your CG envelope.
See all 34 Engineering & Machining Calculators →