Editing / saving a javascript file

I need to edit a javascript file. It is a script for use Zotero / zotfile.

I have edited it in a file with an extension .js.

If I copy it into Script Editor and save it, the file extension becomes .scpt.

If I edit in Text edit and go to save it, I get a dialog which says I can save it as .rtf or .js.rtf but NOT just .js.

I got my son to save it as a .js on his Windows computer and send it back to me via email. The attachment shows on my computer sd .jd.rtf.

This is MacOS Catalina or MacOS Monterey.

I am at a loss how one saves a .js file in MacOS?

Script Editor app is for AppleScript. TextEdit is a plain text or rich text editor. You need a real programming or code editor like Atom, BBEdit, Textastic, SublimeText, TextMate, VSCode, or a million and one other choices, many free.


Agreed - also you can try just changing the file back to xxx.js after you save it.



Edit in TextEdit – but make sure the document is set to plain text (Format>Make Plain Text), not rich text, or TextEdit may do all kinds of screwy things that can break code, like changing straight quotes to “smart” quotes.

Then after saving, e.g. as script.js.txt, go to the file in the Finder and change the filename so the extension is just .js

Longer term, do as @karlnyhus suggests and get to know a code-oriented editor.

1 Like

Also be aware that some text editors change quotes, breaking code.

If you have need to edit code, I might suggest the free mode version of BBEdit. If you download BBEdit, you will get the full version for 30 days. After that, if you choose to pay for it, you get the full version to continue using. Otherwise, it reverts to the free version, which you would find more than sufficient for list code editing duties.

As a long-time BBEdit user, I continue to highly recommend it. It is always open on my computer, and I use it for virtually all text editing tasks. I also write all of my shell scripts and python code in it. (I do use Xcode for larger projects and for Swift due to its built in help and code completion, but that’s more than you need here.)

The other options suggested will also work, eg using TextEdit and saving as .txt and then removing that extension, but you do have to be careful with line endings and you won’t get the syntax highlighting that BBEdit can provide, among other things.

SublimeText is an awesome editor, but I haven’t gone to it primarily because I am so used to BBEdit at this point.


+1 for BBEdit. My oldest license email is for upgrading from version 6.5 to 8.2, in May 2005. Seventeen years ago.

And it still doesn’t suck. :slight_smile:


Visual Studio Code is free and perfect for editing a javascript file. You can download it here:

1 Like

Thank you for all the replies.

As it is a once off and my attempts to edit javascript are rarer than hen’s teeth, I took the suggested path of simply changing the extension on the desktop and that seems to have worked.