I spent some time working on this same problem yesterday. The best and most reliable solution I was able to come up with was to install google-java-format into my path and then use the RunOnSave extension to invoke the binary for files with the .java extension.

Install emeraldwalk/vscode-runonsave:

$ code --install-extension emeraldwalk.RunOnSave

Install google-java-format for your system:

# Example using Homebrew on OS X
$ brew install google-java-format

Configure RunOnSave in Visual Studio Code settings:

{
  "emeraldwalk.runonsave": {
    "commands": [
      {
        "match": "\\.java$",
        "cmd": "google-java-format --replace ${file}"
      },
    ],
  },
}

I describe more of the methodology in this blog post.

Answer from sethvargo on Stack Overflow
🌐
Google
google.github.io › styleguide › javaguide.html
Google Java Style Guide
This document serves as the complete definition of Google's coding standards for source code in the Java™ Programming Language. A Java source file is described as being in Google Style if and only if it adheres to the rules herein.
🌐
GitHub
github.com › google › google-java-format
GitHub - google/google-java-format: Reformats Java source code to comply with Google Java Style. · GitHub
August 14, 2026 - google-java-format is a program that reformats Java source code to comply with Google Java Style.
Author: google
Discussions

visual studio code - Google Styleguide Java Format for VSCode - Stack Overflow
Is there a good extension or proven methodology to automatically format Java code in VSCode to adhere to Google's Java Styleguide? Nothing from the list of links below seems to work for my set-up. More on stackoverflow.com
🌐 stackoverflow.com
Google Java Style Guide
Not that you're saying it is, but Google Java style is not Android Java style. We use these guidelines (except where we don't). More on reddit.com
🌐 r/androiddev
53
124
January 21, 2016
Codestyle and formatters
Spotless? It can use the eclipse formatter which is pretty configurable, or the Google formatter, or others. More on reddit.com
🌐 r/java
27
18
October 21, 2024
forcing coding standards in a team
I would say the most common would be Google Code Style , all this is consistent with all Java conventions. That being said, the most important thing is consistency. Find out what your team are used to and confortable with. More on reddit.com
🌐 r/java
42
43
December 30, 2016
People also ask

Can I customize Google Java Style?
There is no way to customize Google's formatter (google-java-format). Use Checkstyle with changed rules instead if you require flexibility.
🌐
studyunicorn.com
studyunicorn.com › blogs › mastering-google-java-coding-style-guide
Master Google Java Style Guide (2026-27 Update)
Is Google Java Style necessary for small projects?
Although it is not necessary, implementing it in small projects guarantees clear, legible code and fosters positive habits. It also gets code ready for teamwork and easier scaling.
🌐
studyunicorn.com
studyunicorn.com › blogs › mastering-google-java-coding-style-guide
Master Google Java Style Guide (2026-27 Update)
How can I check if my code follows Google Java Style?
Make use of programs such as google-java-format or incorporate Checkstyle into the Google settings setup. This checks and formats your code automatically based on the style guide.
🌐
studyunicorn.com
studyunicorn.com › blogs › mastering-google-java-coding-style-guide
Master Google Java Style Guide (2026-27 Update)
🌐
Studyunicorn
studyunicorn.com › blogs › mastering-google-java-coding-style-guide
Master Google Java Style Guide (2026-27 Update)
July 6, 2026 - When writing Java programs, proper scanner handling in Java ensures resources are managed effectively. Google's Java Style Guide offers an extensive collection of Java programming standards.
🌐
GitHub
github.com › google › styleguide › blob › gh-pages › intellij-java-google-style.xml
styleguide/intellij-java-google-style.xml at gh-pages · google/styleguide
Style guides for Google-originated open-source projects - styleguide/intellij-java-google-style.xml at gh-pages · google/styleguide
Author: google
🌐
Domyassignments
domyassignments.com › home › introduction to google java coding style
Introduction to Google Java Coding Style
March 1, 2024 - In the realm of software development, code readability and consistency are crucial for the maintainability and scalability of projects. The Google Java Coding Style represents a set of guidelines designed to standardize Java code, making it ...
🌐
GDS Way
gds-way.digital.cabinet-office.gov.uk › manuals › programming-languages › java.html
Java style guide - The GDS Way
Always use curly braces around the body of an if, else, for, do or while statement, even if it’s only a single line. Follow the Kernighan and Ritchie (K&R) ‘Egyptian brackets’ style where there is no line break before the opening brace. See the braces section of the Google Java style guide for more details.
🌐
Google
developers.google.com › style › code samples
Code samples | Google developer documentation style guide | Google for Developers
October 10, 2025 - Some open source projects have their own overriding style guides. For example, Java code in the Android Open Source Project follows the AOSP Java Code Style for Contributors guide.
Find elsewhere
🌐
Checkstyle
checkstyle.sourceforge.io › google_style.html
Google's Java Style Checkstyle Coverage
To suppress a check using SuppressWarningsFilter use Java's@SuppressWarnings({"checkstyle:name_of_the_check", ...}) annotation.
Top answer
1 of 7
12

I spent some time working on this same problem yesterday. The best and most reliable solution I was able to come up with was to install google-java-format into my path and then use the RunOnSave extension to invoke the binary for files with the .java extension.

Install emeraldwalk/vscode-runonsave:

$ code --install-extension emeraldwalk.RunOnSave

Install google-java-format for your system:

# Example using Homebrew on OS X
$ brew install google-java-format

Configure RunOnSave in Visual Studio Code settings:

{
  "emeraldwalk.runonsave": {
    "commands": [
      {
        "match": "\\.java$",
        "cmd": "google-java-format --replace ${file}"
      },
    ],
  },
}

I describe more of the methodology in this blog post.

2 of 7
2

google-java-format requires Java 16.0.1 SDK. You have to install it first.

There is an extension ilkka.google-java-format on the Visual Studio Code marketplace, but it is incompatible with current version.

I have to change it this way:

  1. Open file : C:\Documents and Settings\<USERNAME>\.vscode\extensions\ilkka.google-java-format-1.0.2\out\extension.js

  2. Update function provideDocumentRangeFormattingEdits this way:

    return new Promise((resolve, reject) => {
        let stdout = "";
        let stderr = "";
        let child = cp.spawn("java.exe",
            [
                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
                "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
                "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
                "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
                "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
                "-jar",
                executablePath,
                "--lines",
                `${range.start.line}:${range.end.line}`,
                "-",
            ]);
    
  3. In Settings -> Preferences set executablePath to path to jar archive (google-java-format-1.10.0-all-deps.jar)

Enjoy

🌐
Medium
medium.com › @alexprut › integrate-google-java-style-guide-in-a-java-project-567abb6d7987
Integrate Google Java Style Guide in a Java project | by Alex Prut | Medium
July 28, 2019 - Click the Marketplace tab, search for the google-java-format plugin, and click theInstallbutton. The plugin will be disabled by default, you need to enable it manually. Alternatively, you can import the coding style in the IDE.
🌐
GitHub
github.com › google › styleguide › blob › gh-pages › eclipse-java-google-style.xml
styleguide/eclipse-java-google-style.xml at gh-pages · google/styleguide
Style guides for Google-originated open-source projects - styleguide/eclipse-java-google-style.xml at gh-pages · google/styleguide
Author: google
🌐
Medium
medium.com › swlh › configuring-google-style-guide-for-java-for-intellij-c727af4ef248
Configuring Google Style Guide for Java for IntelliJ | by Reed Odeneal | The Startup | Medium
November 16, 2020 - Next to the Scheme drop-down menu select the gear icon then Import Scheme > IntelliJ IDEA code style XML then select the intellij-java-google-style.xml file you downloaded from GitHub. Give the schema a name (or use the default GoogleStyle name from the import).
🌐
DEV Community
dev.to › scottshipp › which-java-code-style-should-you-use-1k5a
Which Java code style should you use? - DEV Community
October 1, 2019 - If you use a build tool like Maven, there are some plug-ins like the fmt-maven-plugin to autoformat code when builds are ran (fmt-maven-plugin uses Google style). That may feel a bit extreme. You may be comfortable with just letting your IDE support this, in which case you would want to get a hold of an XML file for the code style settings that you can import into Eclipse or IntelliJ. It's really up to you. All that being said, you also probably want to grapple with how to approach Java 8+ features like lambdas and streams.
🌐
Reddit
reddit.com › r/androiddev › google java style guide
r/androiddev on Reddit: Google Java Style Guide
January 21, 2016 - Built a Java HTTP Server completely from scratch. ... CSS is driving me insane! ... A community for discussing about CSS (Cascading Style Sheets), Web Design and surrounding relevant topics. Feel free to discuss, ask questions, share projects and do other things related to CSS here. ... Share strange or straight-up awful code. ... The Google Style Guides project holds the C++, C#, Swift, Objective-C, Java, Python, R, Shell, HTML/CSS, JavaScript, TypeScript, AngularJS, Common Lisp, and Vimscript Style Guide.
🌐
Google
google.github.io › styleguide › intellij-java-google-style.xml
intellij-java-google-style.xml
style · ^$ .* ^$ BY_NAME · .*:.*Style · http://schemas.android.com/apk/res/android · BY_NAME · .*:layout_width · http://schemas.android.com/apk/res/android · .*:layout_height · http://schemas.android.com/apk/res/android · .*:layout_weight · http://schemas.android.com/apk/res/android ·
🌐
SourceForge
sourceforge.net › projects › google-java-format.mirror
google-java-format download | SourceForge.net
July 30, 2026 - This is a deliberate design decision to unify our code formatting on a single format. The formatter can be used in software that generates java to output more legible java code. Just include the library in your maven/gradle/etc. configuration.
🌐
Carnegie Mellon University
cs.cmu.edu › ~rdriley › 121 › resources › styleguide
15-121 Java Style Guide
This style guide is an adapted version of Google's Java Style Guide, released under the CC-By 3.0 License, which encourages you to share these documents.
🌐
JetBrains
plugins.jetbrains.com › plugin › 8527-google-java-format
google-java-format Plugin for JetBrains IDEs | JetBrains Marketplace
June 27, 2025 - Formats source code using the google-java-format tool. This plugin requires additional IDE configuration. For more information, read the documentation. What’s New: 1.36.1.1. Move settings page to Tools section. 1.36.1.0. Updated to use google-java-format 1.36.1. 1.35.0.0. Updated to use google-java-format 1.35.0.
🌐
GitHub
github.com › google › google-java-format › wiki
Home · google/google-java-format Wiki · GitHub
Reformats Java source code to comply with Google Java Style. - google/google-java-format
Author: google