A Few of My Favorite Spaces: Space-Filling Curves

Space-filling curves, puzzling maps between dimensions, have surprising real-world applications.

Triple flowsnake, from Patterns of the Universe.

Evelyn Lamb, based on Alex Bellos and Edmund Harriss.

Join Our Community of Science Lovers!

This article was published in Scientific American’s former blog network and reflects the views of the author, not necessarily those of Scientific American


Stop me if you’ve heard this one. Want to see a picture of a space-filling curve? Here you go!

It’s a real knee-slapper! A space-filling curve is basically what it sounds like: a line that gets squiggled around and bent until it fills a 2-dimensional region, in this case a square. (There are 3-dimensional space-filling curves as well, and 4-dimensional and so on. A line can fill as much space as you give it!)


On supporting science journalism

If you're enjoying this article, consider supporting our award-winning journalism by subscribing. By purchasing a subscription you are helping to ensure the future of impactful stories about the discoveries and ideas shaping our world today.


Space-filling curves are not very illuminating in their complete form. What can you learn from a solid black square? Instead, like other fractals, we generally imagine space-filling curves as an infinite version of a finite construction.

There are several ways to make a space-filling curve using an iterative process. Here’s one in animated form. 

At every stage, each line segment is replaced by a figure consisting of four line segments. None of the intermediate curves are space-filling, but if we imagine continuing the process forever, that infinite version is our space-filling curve.

Space-filling curves challenge my intuition dimension. A space-filling curve is the image of a line, a fundamentally 1-dimensional object, that fills a plane, a fundamentally 2-dimensional object. It feels like a well-behaved function shouldn’t be able to turn something 1-dimensional into something 2-dimensional. It’s comforting to me that it only works at infinity, but it’s still a bit unsettling.

(If you’re in a topology class, you should be very nervous. The line and the plane are not topologically equivalent, but a space-filling curve is a continuous function that takes a line to a plane. What’s the matter with it? Have we broken all of mathematics?!)

It’s hard to imagine that something as abstract as an infinitely kinked line could possibly have any relevance to the real world, but the fact that space-filling curves take something 1-dimensional to something 2- or more-dimensional has practical applications in data processing. In this excellent video, Grant Sanderson explains how the Hilbert curve, one example of a space-filling curve, helps us find an optimal way to convert, say, the 2-dimensional visual data of an image into 1-dimensional sound data.

If you want to play along at home, there are lots of ways to make your own space-filling curves. If you want to be cheeky, just start coloring in some squares. If you’re more interested in pondering the infinite iterative process of making the curve, Vi Hart is your guide to drawing dragon curves, and Andrea Hawksley, inspired by Kyle Calderhead, will help you crochet your own Hilbert curve afghan.

As for me, I found my space-filling curve zen in Patterns of the Universe, a math-themed coloring book by Alex Bellos and Edmund Harriss. There are two space-filling curve pages in their book. One is the feature image on this post, and one is the connect-the-dots below.

Image: Evelyn Lamb, based on Alex Bellos and Edmund Harriss.

I spent the first part of the week yelling at people for their bad arguments about math education, and coloring in a flowsnake was the perfect soothing antidote.

Read about more of my favorite spaces: The Cantor Set Fat Cantor Sets The Topologist’s Sine Curve Cantor's Leaky Tent The Infinite Earring The Line with Two Origins The House with Two Rooms The Fano Plane The Torus The Three-Torus The Möbius Strip The Long Line

It’s Time to Stand Up for Science

If you enjoyed this article, I’d like to ask for your support. Scientific American has served as an advocate for science and industry for 180 years, and right now may be the most critical moment in that two-century history.

I’ve been a Scientific American subscriber since I was 12 years old, and it helped shape the way I look at the world. SciAm always educates and delights me, and inspires a sense of awe for our vast, beautiful universe. I hope it does that for you, too.

If you subscribe to Scientific American, you help ensure that our coverage is centered on meaningful research and discovery; that we have the resources to report on the decisions that threaten labs across the U.S.; and that we support both budding and working scientists at a time when the value of science itself too often goes unrecognized.

In return, you get essential news, captivating podcasts, brilliant infographics, can't-miss newsletters, must-watch videos, challenging games, and the science world's best writing and reporting. You can even gift someone a subscription.

There has never been a more important time for us to stand up and show why science matters. I hope you’ll support us in that mission.

Thank you,

David M. Ewalt, Editor in Chief, Scientific American

Subscribe