This method has been posted all over the place, but I haven’t found a good step-by-step walkthrough that explains how and why to show hidden files on a Mac. As my students frequently ask for it, I’m posting here to keep in a reference.

Update Aug 2019: you can do it with a simple keyboard shortcut
– (jump down to keyboard update).

Update 2014: there’s a third-party app for this now
– (jump to app update)

Who’s hiding what?

Have you ever noticed the “extra” files that you can see in your FTP client, yet seem to be missing from the local version of the site on your computer? Chances are, those files are on your local computer too, you just can’t see them. Mac OSX (and other operating systems) hide them by default so there’s less clutter, and so you don’t accidentally delete something important.

The most common example that I come across is the .htaccess file, because I work with WordPress frequently. Note how it begins with the period (dot) because htaccess is actually the file extension, not the file name. Most hidden files will begin with a period.

Sometimes when you’re coding for the web, you need to see the .htaccess and other hidden files to change something about your server setup, usually permalink and server configurtations.

Show hidden files on a Mac

To show hidden files, first open up the Terminal app. If you’ve never used this, it’s here:

Applications → Utilities → Terminal

The terminal window that pops up should look something like this, with your hard drive and user name in place of mine. 

(Fuggles and alturnwall, respectively. Yes, I name all of my hard drives after hops varietals.)

Screen Shot 2013-08-04 at 10.41.56 PM

A quick note before you do anything: using Terminal without knowing what you’re doing can really screw up your computer. It’s not unsafe to do, you just have to be very careful not to type in any commands that you don’t intend to. As such make sure you’ve read the code below carefully and have typed it exactly as written! You have been warned.

Okay now, right after the dollar sign you can go ahead and type or paste in the code below, and press enter.

defaults write AppleShowAllFiles TRUE

Nothing will happen yet, because you need to restart Finder for the changes to take effect. To do this, you can either press option+command+esc to open the Force Quit Applications window, select Finder from the list and hit “Relaunch”, or simply type in the code below in the Terminal window, and again press enter.

killall Finder

If you typed those lines correctly, your desktop icons should disappear for just a second while Finder restarts and the code in your finder window will look like the image screenshot below.

Screen Shot 2013-08-04 at 10.49.29 PM

Now any hidden files on the system should be visible. If you’re not seeing the file you expected, it’s possible that your FTP client is not configured to pull down those hidden files, so you may need to check those settings also. And remember, deleting any system files can break stuff on your computer—if you’re going to go through this process, make sure you’re only editing stuff you know is pertinent to your site, like the .htaccess file.

And, since you don’t want to delete something by mistake, you probably want to hide the files again when you’re done editing your site…

Hide the files again

Back in the Terminal window, we need to basically write the same code again—this time we’re just changing the value of AppleShowAllFiles back to the default of FALSE:

defaults write AppleShowAllFiles FALSE

Again, you need to restart Finder just like you did before with killall Finder or the Force Quit Applications window. And that’s, that.

Update: there’s an app for that.

I just came across a free, lightweight app called Funter that does this for you, and runs unobtrusively in the task bar. (There were lots of apps that did this previously, but they were neither free, nor lightweight.)

Maybe that’s a better option for some folks.

Update Aug. 2019: there’s a keyboard shortcut for that.

As Alesh has commented below, this is now as easy as a keyboard shortcut:

Hitting the period key while holding down Command and Shift, ⌘-⇧-. will show hidden files in finder. Hit it again and they disappear again.

I can confirm that the ⌘-⇧-. method is working in macOS Mojave version 10.14.5 as of Aug 2019.

Thanks so much Alesh for the comment!