20

From Finder, I can preview a plist file without any difficulties. For example, using Quick Look with ~/Library/Preferences/com.apple.Safari.RSS.plist I get a nice preview of its contents:

Quick Look

However, if I then try to open the file, either with TextEdit, or any other editor (I've tried SublimeText, TextMate, Vim, Nano, and Coda 2 so far), the encoding appears to be off:

bplist00Ò_"FixedRefreshesInBackgroundSettings_(com.apple.PreferenceSync.ExcludeSyncKeys ¡ 2]^����������������������������`

Here's what it looks like if I open it with TextEdit:

TextEdit

I've tried changing the encoding in Sublime Text and other apps, but that doesn't help.

Any thoughts?

I'm running 10.8.4.

23

plist files are not necessarily plain text so they need to be run through a converter. Finder and Xcode (which has a plist editor) do this without telling the user

The binary format is documented in this C code so any application can convert it and someone has written a format description in English and more Apple documentation here but note that it references old paths in /Developer/Documentation

The command line program plutil can convert to and from XML

e.g. to view a binary property list in XML format on stdout:

plutil -convert xml1 -o - <file name>

Also to convert a binary to a XML plist in place and then leave it so that the user program can read either.

plutil -convert xml1 <file name>
  • Thanks. I see. So if I need to edit it, I need to convert it to XML, open it with an editor, and then convert it back. I will assume this is so. No need to reply unless I got it wrong! – apc Sep 14 '13 at 14:49
  • 3
    You can also use plutil -convert xml1 ~/Library/Preferences/com.apple.Safari.RSS.plist to convert the plist to XML in place. And after you edit the plist, you don't have to convert it back to binary. – Lri Sep 14 '13 at 15:35
  • 1
    > Finder and Xcode (which has a plist editor) do this without telling the user To be precise, it’s not Finder that’s doing this, it’s QuickLook in the form of a QuickLook plugin. – saagarjha Mar 17 '18 at 8:27
  • You can also use the newer defaults read <file> command to get a kind of JSON view of it. – dlamblin Jun 3 at 5:45
5

You can also edit plist files with PlistBuddy, which is a command-line program.

PlistBuddy is located at /usr/libexec/PlistBuddy.

2

Since you mentioned Sublime Text, there is now a plugin you can use which automatically does the conversion for you:

https://packagecontrol.io/packages/BinaryPlist

0

I made a CMD (Batch) File to assist people with Converting plist files on Windows:
Instructions:
1.Copy all of the code
2.Create a new Text Document
3.Paste the Code
4.Save the File
5.Rename the file with ".bat" instead of ".txt"
6.Open it

    @echo off
    title PLIST Converter ~SyndiShanX
    mode 1000
    color 0b

    ::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Separation-Bar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :filedirectory
    cls
    echo Either: Type the Directory of the File: (Ex. C:\Users\(UserName)\Desktop\File.plist) or Drag and Drop File onto This Window
    echo Made by: [SyndiShanX]
    echo File Directory:
    set /p directory=
    cls

    ::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Separation-Bar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :convertfile
    start "" "C:\Program Files\Common Files\Apple\Apple Application Support\plutil.exe" -convert xml1 %directory%
    goto complete

    ::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Separation-Bar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :complete
    title File Conversion Complete!
    color 0a
    echo File Conversion Complete!
    pause
    cls
    goto exit

    ::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Separation-Bar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :exit
    color 0c
    title Exiting...
    echo Exiting...
    pause
    cls
    exit

Or you can Use the version that doesn't close after conversion to allow multiple conversions without reopening the file:

    @echo off
    title PLIST Converter ~SyndiShanX
    mode 1000
    color 0b

    ::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Separation-Bar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :filedirectory
    cls
    echo Either: Type the Directory of the File: (Ex. C:\Users\(UserName)\Desktop\File.plist) or Drag and Drop File onto This Window
    echo Made by: [SyndiShanX]
    echo File Directory:
    set /p directory=
    cls

    ::~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Separation-Bar~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :convertfile
    start "" "C:\Program Files\Common Files\Apple\Apple Application Support\plutil.exe" -convert xml1 %directory%
    goto filedirectory
  • 1
    Hi, and welcome to Ask Different! This answer may be more useful elsewhere - the OP is not inquiring about the usage of Windows. – Scot May 4 '18 at 1:25
-1

You can convert the property list file from binary format into XML using the following command line:

plutil -convert xml1 -o file.plist file.plist

Then edit it as usual. Secondly you don't have to convert it back, as usually apps recognise both formats.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .