G-Code for Laser Engravers and Pen Plotters

Quick answer

G-code describes machine actions, but its meaning depends on the controller, supported commands and configuration. Start with the machine profile and the intended operation before converting SVG paths. Review units, coordinates, travel moves and laser or pen controls in the generated job. A valid-looking file is not proof that it is suitable for your machine.

Published by: Laserlinez

Do you need a G-Code file?

G-Code is a text-based format for instructions such as movement, feed rate and tool control. An SVG file describes vector graphics; a G-Code file describes operations for a particular controller and setup. Changing the file extension does not convert one into the other.

Check which input your machine software expects. Some workflows accept SVG and generate machine instructions within the software. Others use a separate converter and a G-Code sender. Some machines use other command formats. You do not need to write G-Code by hand to use a workflow that generates it.

This guide covers SVG paths for compatible laser engravers and pen plotters. CNC routing requires CAM decisions such as tool selection and cutting depth; 3D printing requires slicing. Those jobs need their own software and machine setup.

Check the controller before choosing a profile

Identify the controller, firmware version and supported commands in the machine documentation. A profile must match both the command language and the way the machine controls its laser or pen. A file extension such as .gcode or .nc does not establish compatibility.

The command examples below refer to Grbl 1.1. Other firmware, including Grbl derivatives, can behave differently. In Grbl 1.1, G28 moves to a stored position; the homing cycle uses $H when homing is enabled. Do not treat G28 as a universal homing command or copy another machine's startup sequence.

Read a movement command in context

G-Code can retain settings between commands. To interpret a movement, you need to know the active units, positioning mode, feed mode and coordinate offsets.

Grbl 1.1: G21 / G90 / G94
For a reading example in Grbl 1.1, assume G21 selects millimeters, G90 selects absolute positioning and G94 selects units per minute. Under those conditions, G1 X10 Y20 F600 requests a straight move to X = 10 mm, Y = 20 mm in the active work coordinate system, at a programmed feed rate of 600 mm/min. These numbers illustrate syntax; they are not recommended job settings or a complete program.

The programmed feed rate is a target. Acceleration and controller limits affect the actual speed. With G91, the same X and Y values specify relative movements instead of absolute coordinates. G0 denotes rapid positioning; G2 and G3 describe circular motion when supported and correctly specified.

Laser power and pen lifting are different controls

In Grbl 1.1, $32 enables or disables laser mode. With laser mode enabled, M3 selects constant programmed power and M4 adjusts power with actual speed relative to the programmed feed rate. M5 turns the output off. Laser mode avoids unnecessary stops for power changes; it does not disable acceleration. Use the mode required by your machine and job instructions.

S is not a universal percentage. In Grbl 1.1, the configured spindle-speed range, including $30, affects its mapping to output. The generating software and controller must agree on the range. A value copied from another setup can produce a different output.

A pen may be lifted by a Z-axis mechanism, a servo or another device. The required commands and travel depend on that implementation. M3 and M5 are not universal pen-down and pen-up commands. Select a profile that explicitly matches the plotter's pen mechanism.

Prepare the SVG for the intended operation

Confirm the intended physical width and height. SVG width, height, viewBox and transforms determine how coordinates relate to the displayed graphic; converters must interpret them. Explicit physical units help communicate size, but you must still compare the converted dimensions with the intended dimensions. Do not diagnose every size error as an export-DPI problem.

For path-following work, inspect the paths you want the machine to follow. Convert text to paths when the receiving converter requires it. A visible fill does not by itself specify a filled engraving or pen hatching, and an embedded raster image is not a set of vector paths. Check what the converter supports and how it handles unsupported elements.

Remove accidental duplicates and unwanted geometry. Keep intentional repeated passes as an explicit job decision. Open paths are useful for line engraving and pen strokes; close a contour when the intended shape or operation requires it. Simplifying curves changes geometry, so inspect small details after any simplification.

An image needs vectorization when you want paths derived from its pixels. Raster laser engraving is a different workflow and does not generally require converting the image into SVG paths first.

Convert and review the job

  1. Choose compatible software and a profile

    Match the output to the documented controller and tool mechanism. The Laserlinez SVG-to-G-Code service offers three profiles: GRBL 1.1 lasers, lasers on Marlin built with laser support, and G-Code pen plotters that lower the pen with M3 S1000 and lift it with M5 (servo) or use the Z axis (Z0 down, Z5 up). Use it only when one of them matches your setup; other controllers need their own software.

  2. Set the intended dimensions and operation

    Check scale, orientation and placement. Assign the intended line engraving, scoring, cutting or plotting operation. Confirm how paths, colors or groups are interpreted instead of assuming their appearance defines the operation.

  3. Enter settings for your own setup

    Use machine documentation and established material or pen tests to select feed rate, laser output or pen movement. Check units and the controller's output range. There is no single speed or power value suitable for every machine.

  4. Read the report and inspect the preview

    Laserlinez provides a conversion report and an SVG path preview. Resolve reported problems and inspect dimensions, path coverage and travel. The SVG preview shows the moves in the XY plane: cuts in red, engraving in blue, travel as dashed lines and the work zero. It does not show pen lifting, laser power, repeated passes or the final return to the work zero, and very large jobs are drawn with fewer points. These checks do not establish that the machine will operate correctly or that the material will cut through.

  5. Verify the file in the receiving workflow

    Use software compatible with your controller to inspect and transfer the file. Confirm the work origin and movement bounds using the machine manufacturer's procedure. Follow its instructions for testing with the tool inactive, then test the intended operation on suitable scrap material or paper under supervision.

Investigate the symptom before changing settings

  • Wrong size: compare the SVG's intended dimensions, the converter's output dimensions and the units used by the controller. If the file dimensions are correct but the physical result is wrong, investigate the machine setup rather than repeatedly rescaling the file.
  • Mirrored or misplaced result: compare orientation and origin conventions in the converter and receiving software. Apply an axis inversion only when that comparison shows it is needed; an extra inversion can introduce the problem.
  • Pen lines between separate paths: inspect whether the output requests the correct pen-up movement and whether the mechanism actually lifts clear. Do not assume adding M5 fixes every plotter.
  • Rejected commands: compare the reported command with the controller documentation and selected profile. Regenerate compatible output rather than deleting unfamiliar commands indiscriminately.
  • Hesitant movement on curves: dense short segments can contribute, but controller planning, machine limits and data delivery also matter. Supported arc fitting can reduce the number of commands for suitable geometry; it does not guarantee constant speed, a specific file-size reduction or a better physical result.

Before starting the machine

  • The profile matches the controller, firmware and laser or pen control.
  • Units, output dimensions, orientation, work origin and movement bounds have been checked.
  • The intended paths and operations are present; unwanted duplicates or connecting movements have been resolved.
  • Feed rate, output range and tool-control settings are appropriate for this setup.
  • Report warnings have been assessed and a suitable test has been completed using the manufacturer's procedure. A preview alone is not a machine test.

Only after checking its compatibility and job setup. Even machines using the same firmware can differ in dimensions, coordinate configuration and tool control. Keep the source SVG so you can generate output for the intended setup.

No. File size is only one factor. Travel distance, feed rate, acceleration, controller behavior and the physical operation affect job time. Compare the resulting path and machine behavior rather than judging an optimization by file size alone.

The SVG-to-G-Code service is intended for supported laser and pen-plotter profiles. It is not a replacement for the tool selection, depth planning and machining strategies required for CNC routing.

Documentation behind this guide

Convert SVG paths to G-Code

Choose a supported laser or pen-plotter profile, then review the conversion report and path preview for your setup.

Open SVG-to-G-Code conversion

Comments

Please login or create an account to write a comment.

Loading comments...