Apple - Open a large XML file

Depending on the source of the file, you may wish to investigate its contents in other ways than just opening it (double clicking). For this, you should use the command line.

Some suggested starting points (where "whatever.xml" is the name of the file):

file whatever.xml

This will tell you what type the file is. Not by file extension, but by actual examination of the contents.

head whatever.xml

This will show you the first ten lines of the file. However, be warned: It is possible to have an entire 50 MB XML file consisting of a single line. Press Ctrl-C to stop if it starts spewing garbage. (Yes, Control C, not Command-C.)

To just view the file without even the possibility of editing it:

less whatever.xml

If the file does consist of very long lines, for reading it, you could force periodic line wraps (formatting):

fmt whatever.xml | less

But actually, less will wrap the lines by default unless you tell it not to. For no wrapping of lines (so you can use sideways arrow keys to scroll):

less -S whatever.xml

It is a good probability that one of these commands will disclose a problem with the file.


I use Sublime Text 3 to do some of my editing. A very nice and fairly fast programmable (with plugins) editor. I've just tried it on a 50 mb text file and it didn't seem to have a problem. Sublime Text 3 is not free but their free trial period seems to be endless. While I was checking Sublime Text I tried Atom too. Atom was slower at loading but once it got loaded it seemed fine.


My goto editor for large files is BBEdit. I've opened much larger files (200MB+ log files) without any slowdown. I've even used it to open binary files in order to look for ascii strings. If BBEdit can't open it, nothing can.