What is the meaning of the idiom, "Let the cat out of the bag"?

What is the meaning of the idiom, "Let the cat out of the bag"?

Examples: 1. I wanted to give a surprise party for her, but her brother let the cat out of the bag. 2. He was going to surprise her by asking her to marry him at the soccer game, but his best friend let the cat out of the bag. 3. I'm going to tell you a secret about something I'm going to do tomorrow, but first you have to promise not to let the cat out of the bag.

What is the meaning of "Let the cat out of the bag"?

It means to "ruin a surprise by the person know about it."