Inside noun-modifying (relative) clauses:
Pattern:
Note: の replaces が only inside subordinate/modifying clauses, not in main clauses.
In Japanese, the subject-marking particle が can often be replaced by の inside subordinate clauses – most commonly in noun-modifying clauses (relative clauses). Both particles mark the subject in the same way, and the meaning does not change.
When a clause modifies a noun, the subject inside that clause can be marked with either が or の.
Both sentences are natural and have the same meaning. Using の is common in both spoken and written Japanese and can sometimes sound softer or more natural.
This swap can also occur in certain other subordinate contexts, such as clauses ending in とき, まえに前に, あと後で, etc.
This replacement is only possible inside subordinate clauses. In a main clause, が cannot be replaced by の.
However, in a noun-modifying clause, both work: