How to Convert plist Files to XML or Binary in Mac OS X

Convert a plist file to XML or binary in Mac OS X

Plist files contain preference specifics and properties relevant to a particular application or portion of Mac OS X system software. Depending on where the plist file is located and what function they serve, they can either be in XML format, binary format, and sometimes even json. For users who need to modify a plist file or convert the file format to or from XML and binary, you can do so easily in the OS X Terminal with the help of the plutil command.


The great thing about this approach with plutil is that users can convert property list files to XML to make edits with a plain text editor, then back to binary for use by an application or system function again. This prevents the need for using Property List Editor in Xcode to edit plist files, which is a large download and a bit more cumbersome if you don’t need the other development tools bundled with Xcode.

To get started, launch the Terminal, found in /Applications/Utilities/

Converting a plist File to XML from Binary

Have a plist file that is in binary format you want to convert to XML? This can be particularly helpful if you wish to make an adjustment to a property list file in a text editor, without having to launch Xcode or a separate app.

plutil -convert xml1 ExampleBinary.plist

This converts the existing binary plist file into XML format, which can then be edited in just about any plain text editor, whether it’s vi, nano, TextEdit in plaintext mode, or third party apps like TextWrangler and BBEdit. You can also use Xcode to edit plist files as usual.

Converting a plist Binary File to XML Format

Want to convert a plist file in XML format to binary, or back to binary after making edits to it? Use the following command instead:

plutil -convert binary1 Example.plist

This changes the plist in XML back to binary format. Once it’s in binary format it will not be editable with a standard text editor again, unless you convert it back into XML, or use Xcode’s built-in property list editor tool. The modified binary list files can then be placed back into various system level or app level directories as necessary.

By the way, for those wondering why this tool is necessary, simply attempt to open a plist file in binary format with a text editor and you’ll quickly see the problem:

Binary plist file not editable in text editor

The same plist file, when converted from binary to XML, opens in a text editor as a typical XML file which can then be modified as desired, to then convert back to binary again:

Converted plist file into XML format from binary can be edited in text editors

This is obviously aimed at advanced users who need to modify and adjust plist files in the first place, as the average Mac user likely rarely encounters the files let alone needs to make edits to them.

 

[Source:- osxdaily]