A "Mary Sue" (or "Gary Stu" for boys) is a completely perfect character often found in fanfictions. These characters are nearly invincible, multi-talented to the extreme, and loved by all but the reader. Typically, Mary Sue represents the author's idealized version of himself projected into a world of original fiction, also known as canon. Readers can easily spot this fact. Read on for detailed instructions to prevent this annoying character from appearing in your stories.
Steps

Step 1. Know your material
Avoid gossip or everything you saw in two or three episodes. If you can't watch the entire season or read the entire series, that's what the internet is for. Research your fandom.

Step 2. Avoid making your character related to a canon character
While some canon characters have fuzzy pasts that can be manipulated, a frequent and recognizable (but not required) characteristic of a Mary Sue is that she is related, in some way, to a canon character, especially one who already has a strongly established past. It may be hard for your readers to believe that the canon character has a sister who has never been mentioned or a son who does not remember.

Step 3. Give your new character some real flaws
Impatience, obsession with appearances, problematic friends are some examples of character flaws. Remember that they have to be defects with real consequences for the character's life and for the story to advance.

Step 4. Make your character part of the group, it can even be just a small part
Your original character should not be the center of the universe constantly. Let the other characters have their own moments away from your new character, where they don't talk or think about him or her.

Step 5. Let the canon characters share some attention with your character
Remember why they are there. Your readers want to read about canon characters, which is why you are writing a fanfiction.

Step 6. Give the characters different reactions to your original character
Look at the original story you are writing about. Do all the protagonists always agree or do they act in the same way? Of course not. Take into account the personalities of canon characters and create credible reactions and relationships with your character.

Step 7. Make things difficult for your new character
One of the most annoying things about the Mary Sue is how everything comes easily to them: fighting ability, special talents, strong relationships, special powers that appear just in time to save the day, etc. If your character has to fight or deal with real problems, your readers will start to love him. If you do everything perfect without real adversity, they will start to hate you.

Step 8. Prevent your new character from being the only one contributing to solving one of the biggest unresolved conflicts in original fiction
Bring the glory to an established character or make it a real team effort.

Step 9. Be careful with romance
The Mary Sue are constantly winning the love of a character that the author really likes or even two characters who used to be together just because the author thinks they should be together. Romance is possible in fan fiction, but give it time to make it real.

Step 10. Take your time
One of the big mistakes in Mary Sue's stories is that things happen too fast. It will probably take a while for the new character to become close to the canon characters or to be able to accomplish a lot of amazing things. Go slow; you can always write a sequel.

Step 11. Prevent the character from having characteristics like yours
If you do that, you should also start journaling, as everyone has different personalities and should be free to choose what they want to do. Don't base the character's decisions on your opinions, beliefs, etc. This makes the story that much more interesting.
Advice
- Bad habits, like nail biting, can be interesting character quirks, but they're not flaws. One or two bad habits make your character deeper and more interesting, but don't forget to give him a real flaw.
- Flaws are not problems that have to be solved at the end of the story or minor obstacles that disappear at important moments. Your character can gradually overcome certain problems, but he will never stop having defects. If your character is naturally clumsy, he needs to remain clumsy during battles, not just at times when it might be funny for him to fall. If he has a tendency to be a coward, DO NOT make him outgrow him during the first or second (or third or fourth) battle. He can be a coward on many occasions and learn to overcome it over time, but his cowardly tendencies that he thought he was rid of can bring out the best in him when he least expects it. If your character is rude to their superiors, they will be rude too and will be scolded for their flaws.
- The inability to do important things or something that has no influence on your character's daily life is not a fault. A spaceship pilot who can't sing very well is still a perfect spaceship pilot. A member of the troubadour family who cannot sing very well has a real problem.
- Balance strength with flaws. For example, if your character is a handsome, blue-haired teenager who is adept at using the sword and bow, makes others dance and enchants with his ability to play the guitar and is admired by almost all women; make him comically clumsy, scared of spiders, and a bit shy. Also, give him personality flaws, such as arrogance, which makes him unpleasant to his peers; Give him a vice, like a smoking addiction that is bad for his health. Just make sure these flaws have real negative consequences for him and that they don't just make his little quirks more attractive.
- Creating a Mary Sue is not the eighth cardinal sin. Many fanfiction writers begin by imagining what it would be like to meet and interact with the characters in their favorite movies, television shows, books, comics, and video games. But what may be fun for you to imagine may not necessarily be fun for others to read. Don't beat yourself up for writing a Mary Sue story, just think about what you can fix and what you can avoid in the future, so that your character feels more real and competes with everyone.
- Mary Sue's are not limited to fanfiction. Although they are more common and easier to find when the author writes about an already established universe, Mary Sue characters can also be found in original works. Although the above steps do not apply to Mary Sue characters from original stories, they can still be helpful. Of course, when talking about the new character it will refer to your main character, since all the characters are new. But if your main character gets all the attention and glory, stays with all the boys, and never does anything wrong, you probably have a Mary Sue on your hands.
- A rule of thumb: for every two or three good characteristics, create a minor flaw in your character; For every six or nine good features, create a major flaw. That way, your character will be balanced.
- The Litmus test for Mary Sue can help you know if your character is risking entering Mary Sue's territory. Just keep in mind that the most original characters, Mary Sue or not, are going to accumulate some points.
- Well-meaning flaws like "carrying too much" or "trying too hard" can be real flaws, as long as they get your character in trouble. If your character cares a great deal about one person or group of people, it is likely protecting them to the detriment of their mission or preventing them from making a decision that may harm them but does the most good.
- If you find that you've created a Mary Sue and don't want to throw it away, change the genre of your story to parody. If you write a parody, then making a Mary Sue won't be so bad, as long as the parody is funny.
Warnings
- If someone insults your original character for being a Mary Sue, don't take it personally. REVIEW your character and don't assume that she or he is the best and that other writers are 'jealous'.
- If it looks like your main character is a Mary Sue, just admit it. Don't try to convince yourself that it isn't because it probably is. Remember that a Mary Sue can be good if it is written well. Many popular canon characters suffer from having Mary Sue characteristics, but she still has personality.