Understanding the Arduino Sketchbook: Opening and Saving Arduino Sketches

Understanding how the Arduino IDE sets up its file directory system (it’s called the Arduino Sketchbook) can spare you some confusion when it comes to saving, organizing and opening your Arduino sketches (or sketches you have downloaded from the internet).

In this lesson you will learn about:

  1. The Arduino Sketchbook folder
  2. How to change the default location where your Arduino sketches get saved
  3. What happens when an Arduino file does not have an enclosing sketch folder of the same name
  4. Where and how multiple tabs get saved in an Arduino sketch
  5. Why the pancreas of a woodchuck is better suited than our own

You are probably familiar with a file directory system on a computer. It’s usually represented as a hierarchy of folders and files.

An example would be your C Drive – inside the C drive, you may have a folder for Applications, Users, and Systems files. Inside the Users folder, you might have subfolders for Documents, Downloads, Music, etc.

All the files on the computer get organized in this fashion, and Arduino sketches are no exception.

The Arduino Sketchbook Folder and Changing the Default Save Location

The default location where Arduino sketches you write will be saved is called the Sketchbook.

The Sketchbook is simply a folder on your computer like any other. It acts as a handy repository for sketches and is also where add-on code libraries get saved.

You can see the sketches in the Sketchbook folder by going to File > Sketchbook.

The default name of the Sketchbook folder is “Arduino” and the default location of the Sketchbook folder is in the “My Documents” folder (or just “Documents” for Mac users).

If your Sketchbook does not appear to be in this default location, you can see exactly where it is by opening the Arduino IDE and going to Arduino > Preferences.

Arduino Preferences

The default file path for your sketches is listed at the top of Arduino Preferences window. Mine is:

/Users/michaelJames/Documents/Arduino

When I save a file in the Arduino IDE, this “Arduino” folder is the default location where the sketch will be saved, unless I choose to change that location by selecting a different folder on my computer’s directory.

If you want to change this default location, you click the Browse button next to the file directory path and choose a different place. Pretty simple.

Programming Electronics Academy members, check out the Arduino Course for Absolute Beginners to jump start your Arduino programming skills.

Not a member yet?  Sign up here.

Sketch Folders

If you go into your file directory system and open up the Arduino Sketchbook folder (again, named “Arduino” by default), you may see a bunch of folders that you didn’t make.

This is because every Arduino file must be inside a folder that has the same name as the file (there are some exceptions to this that we’ll talk about in a moment).

Let me say that one more time because it is really important to understand.

Every Arduino file must be inside a folder that has the same name as the file

When I write a new sketch and save it, the Arduino IDE automatically creates a new folder that has the exact same name as the sketch itself. The Arduino file (which has the extension .ino) is placed inside this enclosing folder, which is called a sketch folder.

Sketchbook

If you go into the Arduino Sketchbook folder and change the name of the enclosing folder, it will create some issues. The first issue is that when you go to File > Sketchbook, the sketch will no longer show up! If you want to open this sketch you need to go to the .ino file in your directory and open it from there.

If you open a .ino file that is not inside an enclosing sketch folder of the exact same name, then you will get a pop-up from the Arduino IDE that says:

“The file “sketch_name.ino” needs to be inside a sketch folder named “sketch_name”. Create this folder, move the file, and continue?”

Popup

If you choose Cancel, the sketch will not open. If you choose OK, then a folder gets created (it will have the same name as the sketch) and the .ino file is placed inside it.

This sketch folder will be created in whatever directory the .ino file was that you tried to open. For example, if you tried to open a .ino file that was in your My Downloads folder, then the enclosing sketch folder also will be created inside the My Downloads folder.

Saving Tabs in Arduino

The exception to the rule about the sketch folder having the same name as the .ino file is when you create multiple tabs in an Arduino sketch.

The additional tabs do NOT need to bear the same name as the enclosing sketch folder.

Tabs

Now you know what the Arduino Sketchbook is – not as crazy as it sounds!

Once you get a handle on some of these intricacies of the Arduino IDE file system, it can really help to clear things up.

installing Arduino libraries

Installing Arduino Libraries | Beginners Guide

IoT sewage project

Pumping poo! An IoT sewage project

ESP32 webOTA updates

How to update ESP32 firmware using web OTA [Guide + Code]

error message Brackets Thumbnail V1

expected declaration before ‘}’ token [SOLVED]

Compilation SOLVED | 1

Compilation error: expected ‘;’ before [SOLVED]

Learn how to structure your code

16 Comments

  1. Rome on December 28, 2016 at 5:34 pm

    Thank you for the brief but helpful help on getting started with Sketches.
    I am looking forward to taking a look at your other videos&articles!

    • MICHAEL JAMES on January 3, 2017 at 9:23 pm

      Great! I hope you find our site helpful Rome.

  2. D. Vin on November 23, 2017 at 8:37 pm

    A while back I uploaded a sketch to a board (it was the only sketch I have ever uploaded) and neglected to properly record it for future use. Since then I have made a bunch of failed sketches and saved them but never uploaded any of them.

    When I look in my sketch folder there is only one sketch there.

    Is it possible that the sketch folder only consists of sketches that get uploaded? That would be a relief.

    All the rest of these experiments in coding are stored in another place, there’s a bunch of them, all trash.

    • D. Vin on November 27, 2017 at 11:01 am

      Is this discussion dead? I’m looking for some help.

  3. ROBERT OGBURN on August 30, 2019 at 8:41 pm

    D. Vin. I need some help also.
    I have played ,. saved / saved as / a lot in Arduino. the default location (C:\users\engineering\documents\Arduino) has but two folders: ((Neither of which bear any even fleeting resembelence to the stuff I have authored and “saved”…))

    “1” contains – Socket_Arduino_Nano.3dshapes (folder), Socket_Arduino_Nano.pretty (folder) and less than 100 kb of other stuff.

    “Libraries” contains 7 folders and this READ_ME “For information on installing libraries, see: http://www.arduino.cc/en/Guide/Libraries

    • Michael James on August 31, 2019 at 8:47 am

      Hi Robert,

      Out of curiosity when you go to Arduino -> Preferences, is the “Sketchbook Location” the same as the location you have listed above?

      If the files are not being saved there, you might try opening the Arduino IDE, create a new sketch and save it with a unique name, like “Arduino_Test_File” and save it.

      Then search for the file name using your computer’s file directory system, and see where the Arduino IDE is saving your files.

      Hope this helps.

  4. John on May 27, 2020 at 11:35 am

    EXACTLY what I wanted to know! Thanks!!!

  5. Oswald on October 4, 2020 at 8:24 am

    nice info, I just wanted to suggest you could have mentioned about libraries path as well.
    thanks !

  6. Bryan Watson on January 24, 2021 at 3:41 am

    I have put my file inside a file of the same name but it still will not load /

    • Michael James on January 24, 2021 at 5:14 pm

      Are you able to open any other Arduino sketches OK? For example, what about the Arduino examples, can you open those OK?

      Alos, have you tried restarting the Arduino IDE by chance?

  7. mho on January 25, 2021 at 12:53 pm

    Thank you, this was helpful – although I don’t understand why the developers of the IDE forced the users to follow their weird folder-system. I don’t understand why they don’t offer a setting do deactivate this behaviour.
    Also, it would be great if you could add the information about how to add another tab. I wasn’t able to find that out, yet.

    • Michael James on January 25, 2021 at 5:16 pm

      If you’d like, you can change the folder destination under preferences/settings Sketchbook location -though it is recommended to keep the folder named “Arduino”.

  8. John on June 29, 2021 at 4:41 am

    At last I understand and can move forward. What appeared to be very complex has been made clear and obvious.at last.

  9. Jesus Martin on August 7, 2022 at 1:55 pm

    SAVING TABS IN ARDUINO
    The exception to the rule about the sketch folder having the same name as the .ino file is when you create multiple tabs in an Arduino sketch.
    The additional tabs do NOT need to bear the same name as the enclosing sketch folder.

    This has some implications
    When you compile an .ino file it will include and compile together all the files in the sketchbook.
    I discover this the hard way. I have a sketchbook named tes,ini inside a folder called test.ini.
    I make a copy of the file inside the folder and named it test_ver1.ini

    Open test,ino.
    The IDE did not show the other file in another tab.
    I did some changes, and when compiling, I have a lot of errors with duplicating definitions of functions and variables.

    It took me several days to realized that it was compiling both files together.

Leave a Comment