Prior to the upcoming 7.2 release, the Source | Format menu item would be disabled, unless the currently selected window was an editor document.
In 7.2, you can select any of these:
And you can also select multiple nodes, from various kinds, of the above. You'll then see that Source | Format is enabled and functions as you might expect:
When the action is invoked everything within the selected nodes is formatted as defined by the rules defined in the Options window.
Related issue: https://www.netbeans.org/bugzilla/show_bug.cgi?id=67397