Fair Copy
A checker and formatter for JSON, MDX, Power Query M, T-SQL, and BigQuery. It all happens in your browser, and nothing you paste leaves this page.
Bookmark this page to keep these settings.
What it checks
JSON is checked strictly, as the standard (RFC 8259) defines it: strings in double quotes, and no comments or trailing commas. Your browser’s own JSON reader has to agree before Fair Copy calls it valid.
MDX here means Multidimensional Expressions, the query language of Analysis Services cubes. Fair Copy finds unclosed [names], strings, and comments, and unmatched braces and parentheses. It also checks each query’s shape: a SELECT needs FROM and a cube, each axis needs ON and an axis, such as COLUMNS or 0, and each WITH MEMBER or SET needs AS. In scripts, each SCOPE needs an END SCOPE. It doesn’t know your cube’s dimensions and measures, or every MDX function.
Power Query M is read by Microsoft’s open-source M parser, the one behind the Power Query extension for Visual Studio Code. It doesn’t know your data sources, tables, or columns, and nothing is run.
T-SQL and BigQuery checking is limited too, because nothing that runs in a browser reads SQL exactly as SQL Server or BigQuery do. Fair Copy finds unclosed parentheses, strings, and comments, and some unfinished statements, such as a CASE with no END. It doesn’t know your tables or columns, or every rule of each language.
How it formats
JSON is indented with the spaces or tabs you choose, and nothing else changes: numbers too big for JavaScript, and keys that appear twice, come out exactly as you wrote them.
MDX gets WITH, SELECT, FROM, and WHERE on their own lines, each axis and calculated member on a line of its own, and sets, tuples, and functions too long for a line split one item per line. Keywords, function names (including ones after a dot, like .MEMBERS), and flags like BDESC are capitalized, unless you choose As written or lowercase. Names in brackets are never changed. Scripts get one statement per line, indented inside each SCOPE … END SCOPE.
Power Query M is laid out by Microsoft’s formatter for M, with the indent you choose: each step of a let on its own line, and long expressions broken up. M is case-sensitive, so its case is never changed.
SQL gets each clause on its own line, and keywords in the case you choose. Queries come out tidy. Procedural code, such as BEGIN…END blocks and TRY…CATCH, comes out less so.
Before it replaces anything, Fair Copy reads the result back and compares it with what you wrote. If formatting would change more than the layout, it leaves your text alone. After formatting, Undo formatting puts your original back.
Private by design
Everything happens in your browser, including files you open or drop on the text box, which are read there and never uploaded. The code for each language loads from this site the first time you choose it, and apart from that, the page makes no network requests: its content security policy stops it from contacting any other site. What you paste isn’t sent anywhere or stored. Your language and formatting settings live only in the page address after the # sign, which browsers never send to a server, so you can bookmark them. Our privacy policy covers Fair Copy too.
Credits
Fair Copy is built on open-source code: jsonc-parser by Microsoft for JSON; Microsoft’s Power Query parser and formatter for M; and SQL Formatter for SQL. The MDX checking and formatting are Fair Copy’s own. The licenses of these packages, and of the packages they use, are in licenses.txt. Fair Copy isn’t affiliated with Microsoft or with any of these projects.