What is slicing in 3D printing?
Slicing in 3D printing is the step where a computer program cuts a 3D model into hundreds of thin, flat layers and then plans exactly how the printer should draw each one. The program that does this is called a slicer. What it produces is a file of G-code: a long list of instructions like "move here," "push out plastic," and "heat up to 200 degrees."
Think about a loaf of bread. A whole loaf is a 3D shape. If you cut it into slices and lay them out in order, you could rebuild the loaf by stacking them back up. A filament 3D printer works the same way, but in reverse. It "draws" the bottom slice with melted plastic, moves up a tiny bit, draws the next slice on top, and keeps going until the whole object is stacked up.
The printer itself is not very smart. It does not know it is making a phone stand or a chess piece. It just follows the slicer's instructions, one line at a time. That makes slicing the step where all the planning happens.
From idea to object: the five-step workflow
- CAD model You design the object in CAD software.
- STL or 3MF mesh The shape is saved as thousands of tiny triangles.
- Slicer Cuts layers and plans every nozzle path.
- G-code A text file of moves the printer can follow.
- Printer Follows each line and builds the object.
A mesh is a 3D shape made of many flat triangles stuck together, a bit like a disco ball. The STL file format stores only those triangles. The newer 3MF format can also store units, colors, and several parts in one file. Either way, the slicer's job is to turn that shell of triangles into layers and paths for your printer.
In one sentence: slicing turns a 3D shape into a stack of 2D drawings, and then turns each drawing into instructions a machine can follow.
Layer height and walls
Layer height: detail vs. time
Layer height is how thick each slice is, measured in millimeters (mm). It is the most important setting in a slicer, because it decides how many layers the printer has to draw.
Here is the math. A model 40 mm tall printed at 0.2 mm layers needs 40 ÷ 0.2 = 200 layers. Switch to 0.1 mm layers and it needs 400 layers. Twice as many layers takes roughly twice as long. The payoff is a smoother surface, because thin layers make smaller "steps" on curved and slanted sides.
- Thin layers (about 0.1 mm): smooth and detailed, but slow. Good for small figures.
- Medium layers (about 0.2 mm): the everyday choice for a standard 0.4 mm nozzle.
- Thick layers (about 0.28 mm or more): fast, but you can see the lines. Good for rough test parts.
There is a limit. The nozzle squishes each line of plastic flat, so a layer can't be much taller than the nozzle hole is wide. A common guideline is to keep layer height under about three quarters of the nozzle width.
Walls, skins, and the inside
When the slicer looks at one layer, it splits it into three jobs:
- Walls (also called perimeters) are the outlines traced around the edge of each layer. Most slicers default to 2 or 3 walls. Walls give a part most of its strength and make the outside look clean.
- Top and bottom skins are solid layers that cover the part like the crust on a sandwich. A few layers of skin keep the top from looking bumpy or saggy.
- Infill is everything in the middle. That is the next section.
Infill: why prints aren't solid
Infill is the pattern the printer draws inside a part, between the walls. It is set as a percentage. 0% means hollow, and 100% means completely solid. For everyday parts, around 15 to 20% is common.
Why not print everything solid? Because solid prints use a lot more plastic and take a lot longer, and they are often only a little stronger. The walls and skins already carry most of the load, the same way a cardboard box is strong because of its sides, not because it is stuffed full. Infill is like the braces inside a wall: just enough to hold the skin up and stop it from caving in.
Infill patterns
- Grid: two sets of straight lines that cross. Simple and quick.
- Honeycomb: six-sided cells, like a beehive. Stiff, but with lots of short moves, so it is slower.
- Gyroid: a wavy 3D pattern that shifts a little on every layer. It is about equally strong in every direction, so it is a favorite for parts that get pushed and pulled.
Now try it. The slicer playground below slices a small chess pawn, 40 mm tall. Change the settings and watch the layers re-stack, the inside change, and the estimates update.
Try these experiments
- Slide layer height from 0.08 to 0.32 mm. The layer count drops from 500 to 125, and the close-up gets steppy.
- Slide infill from 20% to 100%. How much more plastic does the solid version use? Now set infill back to 20% and add walls instead.
- Drag Show layers up to to the middle, where the pawn's body is. Switch to Gyroid and move one layer at a time. The wavy pattern shifts as you go up.
Overhangs, supports, and bed adhesion
Every layer has to sit on something. Melted plastic can't be laid down on thin air. That causes trouble with overhangs: parts of a model that stick out over empty space, like the arms of a letter T.
A small lean is fine. Each new layer sits mostly on the one below and sticks out only a little. A common rule of thumb says an overhang that leans out more than about 45 degrees from straight up needs help. The exact limit depends on the printer, the plastic, and how well the fan cools each layer.
That help is called supports: thin, temporary columns the slicer adds under overhangs. You snap them off after the print. Supports cost extra plastic and time and can leave marks, so it is often smarter to rotate the model so it doesn't need them. One exception is a bridge: a short, flat span between two pillars. The printer can stretch plastic across it like a rope, so short bridges often print fine with no support.
Try the Letter T upright, then rotate it 180° so it stands on its top bar. The red disappears. For the Arch, notice that only the top of the curve is red: the sides of the curve are steep enough to build up on their own.
Bed adhesion: skirt, brim, and raft
The first layer is the foundation. If it doesn't stick to the print bed, nothing above it will work. Slicers offer three helpers:
Skirt
An outline printed around the part, not touching it. It gets plastic flowing smoothly before the real print starts.
Brim
A flat ring attached to the bottom edge, like a hat brim. It gives corners more grip so they don't curl up.
Raft
A thick platform of layers printed under the part (side view). Useful on tricky beds, but it wastes plastic.
Speed and temperature
Print speed is how fast the nozzle moves, in millimeters per second. Faster saves time, but if you go too fast the plastic can't melt and cool properly, and quality drops. Temperature is set separately for the nozzle and the bed. Each plastic has a range it likes. PLA, the most common beginner plastic, usually prints with the nozzle around 190 to 220 °C and the bed around 50 to 60 °C. The slicer writes these numbers straight into the G-code.
G-code: the printer's program
G-code is a simple programming language for machines. It started decades ago as a way to control CNC machines (computer-controlled cutting tools), and 3D printers adopted it. A G-code file is just text. Each line is one instruction, and the printer runs them in order, top to bottom, just like the code you write in a CodeHS program.
Most lines are moves on a grid of coordinates. X is left and right, Y is front and back, and Z is up and down. E is the extruder: how much filament has been pushed into the hot nozzle so far.
- G0 X40 Y40 is a travel move. Go to (40, 40) without printing.
- G1 X60 Y40 E0.67 is a printing move. Go to (60, 40) in a straight line while pushing filament until the E counter reads 0.67 mm. That draws a line of plastic.
- M104 S200 is a machine command. "M" codes control things that aren't moves, like heaters and fans. This one sets the nozzle to 200 °C.
Step through a real program below. Watch the nozzle follow each line, and notice the difference between orange printing moves and dashed travel moves.
You could write G-code with code
A slicer is a program that writes another program. Here is a tiny version in Python. It prints the G-code for one square layer, using the same math as the player above: each millimeter of line needs about 0.0333 mm of filament.
# Make G-code for one square layer side = 20 x0, y0 = 40, 40 corners = [(x0 + side, y0), (x0 + side, y0 + side), (x0, y0 + side), (x0, y0)] e = 0 print("G0 X40 Y40 Z0.2") for x, y in corners: e = e + side * 0.0333 print(f"G1 X{x} Y{y} E{e:.2f}")
G0 X40 Y40 Z0.2 G1 X60 Y40 E0.67 G1 X60 Y60 E1.33 G1 X40 Y60 E2.00 G1 X40 Y40 E2.66
Where does 0.0333 come from? The line of plastic is about 0.4 mm wide and 0.2 mm tall, so each millimeter of line holds 0.4 × 0.2 = 0.08 cubic millimeters of plastic. Common filament is 1.75 mm thick, so 1 mm of filament holds about 2.4 cubic millimeters. Divide 0.08 by 2.4 and you get about 0.0333. Geometry like this shows up all over making and robotics. See Coding for Geometry for more.
Who reads the G-code? A small computer on the printer's control board, called a microcontroller, reads each line and turns it into exact pulses for the motors and heaters. It's the same idea that runs many robots.
Estimating time and plastic, and fixing failures
Because the slicer plans every single move, it can add them up before you print. It reports the print time and the filament used, often in meters and grams. Those numbers help you decide whether to print a part overnight, at a lower quality, or in smaller pieces. They are estimates. Real printers speed up and slow down at corners, so the actual time can be a bit different.
When a print goes wrong, the fix is usually a slicer setting. Here are common problems and where to look first:
Problem Print won't stick
The first layer peels up or gets dragged around. Try: level the bed and clean it, slow down the first layer, or add a brim.
Problem Corners curl up
Called warping. Plastic shrinks as it cools. Try: a brim, the right bed temperature, or less fan on the first layers.
Problem Droopy "spaghetti"
Plastic was printed onto air. Try: turn on supports, or rotate the model so overhangs are gentler than 45°.
Problem Thin hairs between parts
Called stringing. Melted plastic oozes during travel moves. Try: more retraction (pulling the filament back) or a slightly lower nozzle temperature.
Problem Visible lines on curves
Layer steps are too big. Try: a smaller layer height. Expect a longer print.
Problem Part is weak or cracks
Try: more walls first, then more infill. Gyroid infill helps in every direction.
Problem Bumpy, saggy top
Called pillowing. Try: more top layers or a little more infill to hold the top up.
Problem Gaps and thin lines
Called under-extrusion. Not enough plastic is flowing. Try: lower print speed or a slightly higher temperature.
Slicers are easy to get. Several popular ones are free, some are open source, and many printer makers offer a free slicer with settings already tuned for their machines. They all share the same core ideas you just learned: layers, walls, infill, supports, adhesion, and G-code.
Key terms
- Slicer
- Software that turns a 3D model into layers and G-code for a specific printer.
- Mesh (STL / 3MF)
- A 3D shape stored as many small flat triangles. STL and 3MF are common file formats.
- Layer height
- How thick each layer is, in millimeters. Thinner is smoother but slower.
- Walls / perimeters
- The outlines traced around the edge of each layer. They give most of the strength.
- Top and bottom skin
- Solid layers that close off the top and bottom of a part.
- Infill
- The pattern printed inside a part, set as a percentage from 0% (hollow) to 100% (solid).
- Overhang
- Part of a model that sticks out over empty space.
- Supports
- Temporary structures printed under overhangs and removed afterward.
- Bridge
- A short flat span printed in the air between two supported points.
- Skirt, brim, raft
- First-layer helpers: an outline, an attached ring, and a full platform under the part.
- G-code
- The line-by-line instruction language that 3D printers and CNC machines follow.
- Extrusion (E)
- Pushing filament through the hot nozzle. In G-code, E tracks how much has been pushed.
- Retraction
- Pulling filament back a little before a travel move, so plastic doesn't ooze.
- Nozzle
- The heated metal tip that melted plastic comes out of. 0.4 mm wide is the most common size.
Quick answers
What is slicing in 3D printing?
Slicing is the step where software cuts a 3D model into many thin, flat layers, like slicing a loaf of bread, and then plans the exact path the nozzle will follow on each layer. The result is a G-code file: a list of instructions the 3D printer follows one line at a time.
What is a slicer?
A slicer is a program that turns a 3D model file, usually an STL or 3MF file, into G-code for a specific printer. You choose settings such as layer height, walls, infill, supports, speed, and temperature, and the slicer works out every move. Several popular slicers are free to download.
What is infill in 3D printing?
Infill is the pattern printed inside a part, between its outer walls. Most prints are not solid. An infill of 15 to 20 percent is common for everyday parts, because it saves plastic and time while the walls carry most of the strength. Common patterns include grid, honeycomb, and gyroid.
What is G-code?
G-code is the programming language 3D printers and CNC machines follow. Each line is one instruction. For example, G1 X60 Y40 E0.67 means move in a straight line to the point X 60, Y 40 while pushing out filament. G0 is a travel move with no plastic, and M commands control things like heaters and fans.
What layer height should I use?
With the common 0.4 mm nozzle, 0.2 mm is a good everyday layer height. Thinner layers, such as 0.12 mm, look smoother but take longer because the printer must make more layers. Thicker layers, such as 0.28 mm, print faster but show visible steps. A common guideline is to keep layer height below about three quarters of the nozzle width.
When does a 3D print need supports?
A rule of thumb is that any part of a model that leans out more than about 45 degrees from straight up needs support, because each layer must rest mostly on the layer below. Short flat spans between two pillars, called bridges, can often print without support. Rotating the model on the bed can remove the need for supports.
Are slicer programs free?
Yes, many are. Several widely used slicers are free, and some are open source. Many printer makers also provide a free slicer with ready-made settings for their machines. They all do the same basic job: turn a model into layers and G-code.
Quick quiz
1. A model is 30 mm tall. How many layers does it need at a 0.2 mm layer height?
2. Why are most 3D prints NOT printed at 100% infill?
3. What does the G-code line G1 X60 Y40 E0.67 tell the printer to do?
4. A letter T is printed standing upright, and its arms come out droopy. What is the best fix?
Keep learning
Write the code that makes things move
A slicer is a program that writes instructions for a machine. CodeHS courses teach you to write programs like that, from your first loop to robotics and physical computing.