Request a Personalized Demo

Learn how to accurately convert your designs with Scan2CAD

  • Join thousands of happy customers worldwide

CNC Guide: How to Convert DXF to G-Code

CNC cut paper design held in front of mountains and river

If you’re unfamiliar with CNC (Computer Numerical Control), it enables machines like laser cutters and water jets to transform computer-based designs into physical products. For example, fancy creating a new sign for your store? All you need is your chosen design and a CNC machine. In order for the machine to read the file, however, it must be in the form of what is known as ‘G-Code’.

Converting your files to G-Code does not have to be a complicated process. If you’re starting out with an accessible file type like DXF, it’s actually really easy. No need to learn code—just use software that can do the work for you.

This article explores what DXF and G-Code actually are, and how you can convert from one to the other in a few simple steps.

Table of Contents

What is DXF?

DXF icon

DXF is a vector graphic file type that has become the standard format for data exchange. Indeed, the full name for this file type is actually Design eXchange Format. Created in 1982 by Autodesk, it’s particularly useful for sharing designs across different CAD programs. The files have an open source format and enable people to access AutoCAD drawings, for instance, without the need to use Autodesk applications. DXF files are a sound choice if you’re working with 2D vector images, and a great starting point if you’re looking to convert to G-Code. 

What is G-Code?

G-Code is a programming language made up of letters and digits. It’s largely associated with CNC machines, but can also be used in 3D printing and photoplotting. In terms of the former, G-Code tells CNC machines where and how to move. Using what are called Cartesian coordinate locations, the machine is fed instructions including direction, speed and depth—thus enabling it to create products from a computer image.

G-code sample

An example of G-Code within a CNC editor. As you can imagine, it’s not easy to write the code yourself unless you’re an experienced CAM programmer!

The G-Code itself looks quite complex and can be intimidating if you’re new to CNC. Don’t let that put you off, though—you certainly don’t need to be a code breaker to work with these tools! Rather than writing the G-Code yourself, or attempting to modify existing G-Code, you have the option of using CAM software or CAD editing programs to produce the code.

Why Convert DXF to G-Code?

CNC projects can be fun, satisfying and educational. Plus, they allow you to create a huge variety of useful products. Tools, furniture, machine parts and even jewellery can be made using CNC machines. The possibilities are almost endless!

If you’re new to CNC, or want to simplify the process of using CNC machines, DXF files are a particularly useful place to start. Designs saved in the DXF format don’t need to be vectorized, so you can export them directly to G-Code using programs like Scan2CAD and they’ll be ready to cut!

Wondering where to begin? Have a browse through these 13 sites with free DXFs. You can also receive free DXF packs directly from Scan2CAD—simply enter your email in the box at the bottom of the page to sign up and get exploring. Use the designs as inspiration for your own work, or start experimenting straight away!

Using Scan2CAD to Convert Your Files to G-Code

We’re going to show you how to use Scan2CAD to convert your files to G-Code. There’s no need to start stressing about learning a new programming language—in a few simple clicks, the job can be done for you.

Scan2CAD makes it easy to directly export a vector image to G-Code. All you have to do is open up your DXF file in Scan2CAD and save it as G-Code. You have three options when it comes to the G-Code file extensions Scan2CAD supports: .CNC, .NC and .TAP. Make your choice based on which one is compatible with your particular CNC machine. The three listed are some of the most popular types, so you shouldn’t have any trouble. Transfer the files to your machine and production can begin. Simple!

If you need to get specific with the export settings, no problem—Scan2CAD’s CNC Export dialog presents a range of settings that you can tweak to meet your requirements:

  • G-Code Bezier options – use cubic splines, arcs or polylines
  • Arc and Circle Rotation – rotate clockwise or anticlockwise 
  • Z Settings – Set the Z Offset, Z Max for Passes, Z Limit per Pass and Z Retract per Pass
  • Scaling – set the required scale, either via the Menu or when prompted to upon saving.

As you can see, the conversion process can be as simple or detailed as you want it to be, depending on your CNC knowledge. So, whether it’s a new hobby or something you want to use to benefit your business, explore the potential of CNC today!

Download Scan2CAD Free Trial


One monthly email featuring the best guides for CAD professionals.

14 Responses to CNC Guide: How to Convert DXF to G-Code

  1. Ali saleh m mahdi Jun 25, 2018 at 11:28 AM #


    I want to know how to generate the path of clean out shape.

    Any idea please. . .

    • Luke Kennedy Jun 25, 2018 at 11:37 AM #

      Could you describe what you mean by ‘clean out shape’?

      and what software are you using?

  2. Ali saleh m mahdi Jun 25, 2018 at 11:48 AM #

    Sorry about my English.
    I mean if I have circular shape and i want to engraving all the inside the shape by router how i can generate the tool path.

    • Luke Kennedy Jun 25, 2018 at 11:54 AM #

      If you have a circular vector shape in your vector file, you can simply use Scan2CAD to save it to G-Code format.

      And almost any CNC software will support this file format.

      There’s nothing else you’ll need to do.

      • Ali saleh m mahdi Jun 25, 2018 at 12:02 PM #

        I design the hardware cnc controller and I wants to do the software. . .

        • Luke Kennedy Jun 25, 2018 at 12:23 PM #

          I’m afraid I don’t understand your question. You could post any questions like these to the community at

  3. Martin Wilcox Oct 5, 2018 at 12:37 PM #

    Having trouble finding a g code that will work with our baileigh CNC plasma table. The torch will trace the shape of the part but not cut it. What are we doing wrong?

    Thank you.

    • luke Oct 5, 2018 at 12:43 PM #

      Most likely a setting with your CNC controller software has to be altered. I would refer to the support for your table and/or controller software.

      It’s not likely a problem with the designs but rather getting to grips with the settings required for your setup.

  4. Wesley Feb 21, 2019 at 7:58 AM #

    Hi guy,s thanks for the great article. I have a solution that required 4 axes to be controlled; linear axes X, Y, Z and a rotational axis (J). Can your software generate 4 dimensional G-code?

    • luke Feb 23, 2019 at 3:58 PM #

      Hey Wesley, Does the original file that you’re converting contain this information? If not you would need to manually add it afterwards.

  5. Gavin Apr 1, 2019 at 1:11 PM #

    Hi, we have a Bystronic water jet cutter recently acquired, but most of the files we get and have already are in DXF. We need them to be LCC NCP as we don’t want to think about having to redraw everything in Bystronic software. is there a convertor software that we can use with our DXF files?

    • luke Apr 1, 2019 at 1:21 PM #

      I don’t know of anything that converts to .lcc or .ncp they are not commonly required therefore there’s not going to be many apps that support this.

  6. Alfredo Herrera May 10, 2019 at 6:11 AM #

    Hello! I’m just learning to work on a CNC. I’ve been looking for DXF files on the web so I can practice and I found some particular projects where the file has a .DXF extension but when I open it I get some kind of coding, rows numbered from 0 to whatever with different text instructions, such as this:

    Is there any way to turn this into a vector file? Can this coding be used directly on the CNC (I’m using ArtCam and Autocad for the design part).
    Thank you.

    • Luke May 10, 2019 at 10:54 AM #

      DXF files are vector files.

      You’re just looking at the ASCII code of the file.

      If you want to convert the DXF to G-Code you can do that with Scan2CAD.

      I recommend asking other questions like these over at CAD Answers.

      Good luck.

Leave a Reply