Your sentence is perfectly understandable but it can be improved.
Placing the adverb
trop being a short adverb we would rather place it before the infinitive1.
De parfaits inconnus
The article de is used instead of des when the noun it determines is preceded by an adjective.
So we could have: j'ai l'habitude de trop partager avec de parfais inconnus.
trop partager could be an option, but trop partager hasn't acquired in French the meaning "overshare" has over the past 20 years. French has not yet established a standard way of saying we reveal an (often inappropriate) amount of details about our personal life, which is what oversharing is about.
If the information you share is just about yourself (which oversharing usually is) you could say:
- J'ai l'habitude de trop parler de moi avec de parfaits inconnus.
- J'ai l’habitude de trop me confier à de parfaits inconnus.
- J'ai l’habitude de trop me dévoiler à de parfaits inconnus.
If you mean that the information you share isn't only about yourself then I would suggest :
- J'ai l'habitude de dévoiler trop d'informations à de parfaits inconnus.
In any of these examples avoir l'habitude de could be replaced by avoir pour habitude de. The difference between the two is really very slight and in this particular sentence it would not make any difference. A post there explaining the difference, when one can be perceived.
1This remark cannot be generalised, placing the adverb is quite subtle in French.